我已经尝试了很多来自这个网站和其他人的代码......但似乎没有任何工作适合我。这里是我的代码...如何改变按钮点击屏幕的方向?
- (IBAction)orientation:(id)sender {
self.currentDeviceOrientation = [[UIDevice currentDevice] orientation];
int cur = self.currentDeviceOrientation;
int port = UIInterfaceOrientationPortrait;
int landl = UIInterfaceOrientationLandscapeLeft;
int landr = UIInterfaceOrientationLandscapeRight;
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
{
NSNumber *value= [NSNumber numberWithInt:UIDeviceOrientationLandscapeLeft];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"orientation"];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
}
}
上的一个按钮的点击,我想在屏幕从当前方向即发生改变,如果屏幕处于纵向模式时,应该改为横向和副诗。
的[我如何编程在iOS7设置设备的方向?(可能的复制http://stackoverflow.com/questions/20987249/how-do-i-programmatically-set-device-orientation-in- ios7) –