IOS UISplitViewController之 解决 密码框添加之后 调用子视图的转向方法之时 对象为空
2012-08-20 11:12
811 查看
在上一篇中 IOS UISplitViewController之 添加启动密码,在添加完 启动密码后,调用此方法:
在 (UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:ButtonItem;
方法中调用下面的语句,保存 master 的按钮(因为时系统作为参数传递过来的),在手动调用时要用到
profileBarButtonItem = barsplitViewController:
时,因为 转向方法 早于
解决办法为 为需要转向的 子视图对象 添加get 方法
如下 :
就可以啦
但是 如果,子视图对象 为 nib 文件 的IBOutlet 对象的话,此时你如果还想转换位置,
可以
在willRotateToInterfaceOrientation:duration:
方法中将方向存储起来:
DrviceOrientation = toInterfaceOrientation;
然后在viewDidLoad方法中使用 :
如下:
在 (UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:ButtonItem;
方法中调用下面的语句,保存 master 的按钮(因为时系统作为参数传递过来的),在手动调用时要用到
profileBarButtonItem = barsplitViewController:
- (void)passcodeViewDidDismiss { UIInterfaceOrientation orientation = self.splitController.interfaceOrientation; UIInterfaceOrientation masterFrom = self.masterController.interfaceOrientation; UIInterfaceOrientation detailFrom = self.detailController.interfaceOrientation; [self.masterController willRotateToInterfaceOrientation:orientation duration:.1]; [self.detailController willRotateToInterfaceOrientation:orientation duration:.1]; [self.masterController didRotateFromInterfaceOrientation:masterFrom]; [self.detailController didRotateFromInterfaceOrientation:detailFrom]; CGFloat deviceHeight = [[UIScreen mainScreen]applicationFrame].size.height; if (1024 == deviceHeight) { //只有当设备是横屏显示时 [self splitViewController:splitController willShowViewController:masterController invalidatingBarButtonItem:nil]; // 分割视图在 添加密码框时,启动时不会走此方法,所以需要手动调用 } else { [self splitViewController:splitController willHideViewController:masterController withBarButtonItem:profileBarButtonItem forPopoverController:self.currentPopover]; } }
时,因为 转向方法 早于
masterController与
detailController的loadView 和 viewDidLoad 等方法,所以 此时 其中的子对象都为空,转向操作不起作用,
解决办法为 为需要转向的 子视图对象 添加get 方法
如下 :
- (RecentsViewController *)recentsController { if (recentsController != nil) { return recentsController; } recentsController = [[RecentsViewController alloc]init]; return recentsController; }
就可以啦
但是 如果,子视图对象 为 nib 文件 的IBOutlet 对象的话,此时你如果还想转换位置,
可以
在willRotateToInterfaceOrientation:duration:
方法中将方向存储起来:
DrviceOrientation = toInterfaceOrientation;
然后在viewDidLoad方法中使用 :
如下:
if (UIInterfaceOrientationIsLandscape(DrviceOrientation)) { self.topView.frame = kTopLandscape_Frame; self.bottomView.frame = kBottomLandscape_Frame; } else { self.topView.frame = kTopPortrait_Frame; self.bottomView.frame = kBottomPortrait_Frame; }
相关文章推荐
- iOS开发 控件不能绑定拖动到视图ViewController连接的解决方法
- 【IOS】分隔视图控制器 (UISplitViewController)
- ios UIImageView添加图片动画效果,添加了手势之后,依然没有反应的解决方法
- iOS 6编程--分割视图控制器(UISplitViewController)和Master-Detail Application模板
- iOS开发手记 - iOS9.3 UINavigationController添加后不显示storyboard中viewcontroller里的控件的解决方法
- dlg中获得view视图对象 包含view头文件出错 解决方法
- iOS UISplitViewController 开发(iOS8)
- 分割视图控制器(UISplitViewController)
- IOS UI:弹出视图/弹出模态 presentViewController与presentModalViewController(增加IOS 6.0说明)
- iOS UISplitViewController 使用教学
- iPad 自定义UISplitViewController 无法横屏的解决办法。
- 对话框子视图Android自定义Dialog二次调用报错解决方法:The specified child already has a parent. You must call removeView()-java教程
- UISplitViewController - iPad分屏视图控制器
- [ IOS ] 视图控制对象ViewController的生命周期
- iOS解决使用模态视图 导致无法pushViewController
- 添加子视图控制器时,子视图控制器的viewWillAppear方法不调用
- github添加ssh key之后push还要输入账号密码的解决方法
- 【iOS开发-107】UISplitViewController:如何取得master和detail控制器,核心在于如何运用代理
- 分割视图控制器(UISplitViewController)
- UI: 用 UISplitViewController 显示 Master-Detail 视图 ;使用 UIPageViewController 启用分页;使用 UIPopoverController 显示弹出画面(弹出框)