[英]iPhone - getting device orientation in first view controller's view will appear
[英]i want to know device orientation when the view will appear IOS 6
我想知道視圖出現時的設備方向。 以前可以使用shouldAutorotateToInterfaceOrientation
方法,但在IOS 6中它已被棄用。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation==UIInterfaceOrientationPortrait ||interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown ) {
DashBtn.hidden=NO;
}
else
{
DashBtn.hidden=YES;
if (self.popoverControllerMain) {
[self.popoverControllerMain dismissPopoverAnimated:YES];
}
}
return YES;
}
我檢查了所有帖子,即制作rootviewcontroller和
- (BOOL)shouldAutorotate {
return NO;
}// this method is not called
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
嘗試使用
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
代替
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
創建UINavigationController的類別並添加以下代碼@implementation UINavigationController(Rotation_IOS6)
- (BOOL)shouldAutorotate {return [[self.viewControllers lastObject] shouldAutorotate]; }
- (NSUInteger)supportedInterfaceOrientations {return [[self.viewControllers lastObject] supportedInterfaceOrientations]; }
@結束
了解設備方向的最佳選擇是
[[UIApplication sharedApplication] statusBarOrientation]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.