> FirstVIEwController
> SecondVIEwController
> ThirdVIEwController
目标是:通过SecondVIEwController呈现ThirdVIEwController.
在FirstVIEwController中,我使用下面的方法呈现SecondVIEwController:
[self presentModalVIEwController:secondVIEwController animated:NO];
当加载SecondVIEwController时,我在-vIEwDIDAppear中呈现ThirdVIEwController:委托回调方法:
- (voID)vIEwDIDAppear:(BOol)animated{ [super vIEwDIDAppear:animated]; [self presentModalVIEwController:thirdVIEwController animated:NO];}
因此,我认为现有视图控制器的方案已为我们所有人所知.也许代码的设计不好,但我已经制定了这个解决方案并且有下面描述的问题.
当加载ThirdVIEwController时,我遇到了20分的问题(但仅适用于iOS 4.3,其他版本运行良好).
我有附件显示我的问题.
正如你在左侧看到的那样,我有不必要的偏移量.旋转屏幕后,此问题消失.
当我打印ThirdVIEwController视图框架时,它显示frame =(0 0; 480 300).也许是SecondVIEwControllers视图中的问题.
关于轮换.我已经在每个控制器中实现了以下这些方法:
- (BOol)shouldautorotate{ return YES;}- (NSUInteger)supportedInterfaceOrIEntations{ return UIInterfaceOrIEntationMaskLandscape;}- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation{ if (interfaceOrIEntation==UIInterfaceOrIEntationLandscapeleft || interfaceOrIEntation==UIInterfaceOrIEntationLandscapeRight) return YES; return NO;}
(更新:)是的我现在发现了问题,SecondVIEwController帧=(0 20; 300 480);但我不明白为什么.
我添加此方法以检查当前方向:
-(voID) getCurrentOrIEntation{ UIInterfaceOrIEntation orIEntation = [[UIDevice currentDevice] orIEntation]; if(orIEntation == UIInterfaceOrIEntationPortrait){ NSLog(@"portrait"); } else if(orIEntation == UIInterfaceOrIEntationLandscapeRight) { NSLog(@"LandscapeRight"); } else if(orIEntation == UIInterfaceOrIEntationLandscapeleft) { NSLog(@"Landscapeleft"); }}
并在-vIEwDIDAppear:方法中检查它,它显示当前方向是纵向而不是我在shouldautorotatetoInterfaceOrIEntation回调中设置的横向模式.
此外,我发现对于iOS iOS 4.3,它的效果很好.
我在iPhone模拟器上做了所有测试.
我已将此代码添加到我的基本视图控制器,但它仍然不适合我.
- (voID)willRotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)toInterfaceOrIEntation duration:(NSTimeInterval)duration{ if (UIInterfaceOrIEntationIsLandscape(self.interfaceOrIEntation)) { //Landscape orIEntation code if (IS_IPAD) { [self.vIEw setFrame:CGRectMake(0,1024,748)]; } else if (IS_IPHONE) { [self.vIEw setFrame:CGRectMake(0,480,300)]; } else if (IS_IPHONE_5) { [self.vIEw setFrame:CGRectMake(0,568,300)]; } NSLog(@"landscape"); NSLog(@"%@",[NSValue valueWithCGRect:self.vIEw.frame]); }else { //portrait orIEntation code NSLog(@"portrait"); }}
(工作更新:)
我使用下面的代码解决了这个问题:
[UIApplication sharedApplication].statusbarHIDden = YES;if (self.thirdVIEwController) self.thirdVIEwController = nil;self.thirdVIEwController = [[ThirdVIEwController alloc] initWithNibname:@"ThirdVIEwController"] bundle:nil];[self presentModalVIEwController:self.self.thirdVIEwController animated:NO];[UIApplication sharedApplication].statusbarHIDden = NO;解决方法 亚历山大,请你试试下面的代码.它工作在4.3(添加到SecondVIEwController):
- (voID)willRotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)toInterfaceOrIEntation duration:(NSTimeInterval)duration { [super willRotatetoInterfaceOrIEntation:toInterfaceOrIEntation duration:duration]; [UIApplication sharedApplication].statusbarHIDden = YES;}- (voID)vIEwDIDAppear:(BOol)animated { [super vIEwDIDAppear:animated]; AMThirdVIEwController* th = [[AMThirdVIEwController alloc] initWithNibname:nil bundle:nil]; [self presentModalVIEwController:th animated:NO]; [UIApplication sharedApplication].statusbarHIDden = NO;}总结
以上是内存溢出为你收集整理的iOS 4.3用户界面方向问题,带有20个状态栏全部内容,希望文章能够帮你解决iOS 4.3用户界面方向问题,带有20个状态栏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)