我想知道設備的方向,當視圖出現。 以前有可能使用shouldAutorotateToInterfaceOrientation
方法,但在IOS 6中不推薦使用。我想知道設備的方向,當視圖出現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;
}
但是當第一個視圖加載...即不爲旋轉裝置 – shyla
@shyla你必須寫在'代碼,它不會叫 - (無效)viewDidLoad'或' - (空隙)viewWillAppear中:(BOOL)animated' –