
我正在呈现这样的模态
- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // OverrIDe point for customization after application launch. self.vIEwController = [[VIEwController alloc] initWithNibname:@"VIEwController" bundle:nil]; UINavigationController *navController = [[UINavigationController alloc] initWithRootVIEwController:self.vIEwController]; self.window.rootVIEwController = navController; [self.window makeKeyAndVisible]; LoginVIEwController *lvc = [[LoginVIEwController alloc] initWithNibname:@"LoginVIEwController" bundle:[NSBundle mainBundle]]; [self.window.rootVIEwController presentModalVIEwController:lvc animated:NO]; return YES;} 在LoginVIEwController中
- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation{ // Return YES for supported orIEntations NSLog(@"%@",NsstringFromCGRect(self.vIEw.frame)); return UIInterfaceOrIEntationIsLandscape(interfaceOrIEntation);} 几次轮换后的日志结果:
2012-03-06 13:51:49.308 OrIEntationTest[3132:207] {{0,0},{1024,748}}2012-03-06 13:51:49.310 OrIEntationTest[3132:207] {{0,748}}2012-03-06 13:51:49.313 OrIEntationTest[3132:207] {{0,20},748}}2012-03-06 13:51:49.314 OrIEntationTest[3132:207] {{0,{748,1024}}2012-03-06 13:51:49.315 OrIEntationTest[3132:207] {{20,1024}}2012-03-06 13:51:50.991 OrIEntationTest[3132:207] {{20,1024}}2012-03-06 13:51:51.647 OrIEntationTest[3132:207] {{20,1024}}2012-03-06 13:51:51.648 OrIEntationTest[3132:207] {{0,1024}}2012-03-06 13:51:53.481 OrIEntationTest[3132:207] {{0,1024}}2012-03-06 13:51:53.482 OrIEntationTest[3132:207] {{0,1024}}2012-03-06 13:51:53.897 OrIEntationTest[3132:207] {{0,1024}}2012-03-06 13:51:53.898 OrIEntationTest[3132:207] {{20,1024}} 基本上,loginVIEwController就像在纵向模式下一样.我在这个视图上有两个文本字段,当我点击其中一个时,我想向上移动视图,因此键盘不会显示在文本字段上.为了做到这一点,我必须修改frame.origin.x而不是y因为轴被反转(视图就像肖像),这导致了很多问题.
编辑:
如果我将LoginVIEwController上的模态演示样式更改为UIModalPresentationPageSheet,它按预期工作,因此仅在全屏模式下出现问题
第二编辑:
我已经将代码简化为基础知识.我甚至不再提供模态视图控制器只是将该视图控制器初始化为根视图控制器并且仍然发生这种情况.
应用代表:
- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // OverrIDe point for customization after application launch. self.vIEwController = [[VIEwController alloc] initWithNibname:@"VIEwController" bundle:nil]; self.window.rootVIEwController = self.vIEwController; [self.window makeKeyAndVisible]; return YES;} 在我的视图控制器中:
- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation{ // Return YES for supported orIEntations NSLog(@"%@",NsstringFromCGRect( self.vIEw.frame)); return UIInterfaceOrIEntationIsLandscape(interfaceOrIEntation);}解决方法 好的,所以我终于找到了一种方法来正常工作.看起来如果你只是创建一个新的视图控制器并表明它将始终被反转.我找到的修复程序是将视图控制器放在导航控制器中. LoginVIEwController *lvc = [[LoginVIEwController alloc] initWithNibname:@"LoginVIEwController" bundle:[NSBundle mainBundle]];UINavigationController *nvc = [[UINavigationController alloc] initWithRootVIEwController:lvc];nvc.navigationbarHIDden = YES;lvc.modalPresentationStyle = UIModalPresentationFullScreen;lvc.parentVIEw = self.navController.vIEw;[self.window.rootVIEwController presentModalVIEwController:nvc animated:NO];总结
以上是内存溢出为你收集整理的iphone – iPad模态视图控制器,即使它的风景也在纵向全部内容,希望文章能够帮你解决iphone – iPad模态视图控制器,即使它的风景也在纵向所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)