相关疑难解决方法(0)

支持多种方向的最简单方法?当应用程序在Landscape中时如何加载自定义NIB?

我有一个应用程序,我想支持多个方向.我有两个.xib文件,我想使用myViewController.xib myViewControllerLandscape.xib. myViewController.xib并存在于project/Resources中,myViewControllerLandscape.xib并存在于根项目目录中.

我想要做的是使用单独的NIB (myViewControllerLandscape.xib)进行轮换.我尝试在viewDidLoad like中检测旋转:

if((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight))
 {
  NSLog(@"Landscape detected!");
  [self initWithNibName:@"myViewControllerLandscape" bundle:nil];

 }
Run Code Online (Sandbox Code Playgroud)

但我可以在gdb中看到,当应用程序以横向设备启动时,不会执行此操作.NSLog消息不会触发.为什么是这样?我做错了什么?

此外,如果我initWithNibNameviewDidLoad方法中明确地放置了函数调用,则不会加载该nib,并继续使用myViewController.xib文件.我的电话有什么问题?我应该指定捆绑吗?

谢谢!

iphone xib uiviewcontroller nib iphone-sdk-3.0

35
推荐指数
3
解决办法
3万
查看次数

想要将muliple笔尖用于不同的iphone接口方向

我有一个情况,我创建了两个不同的笔尖,一个在纵向模式,另一个在横向模式.我在视图中有很多设计,所以我不得不选择两个不同的笔尖.现在,我想在界面旋转时切换笔尖

常见的viewController

这样我就可以保留填充值和视图中控件的状态.

现在我正在使用

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Override to allow orientations other than the default portrait orientation.
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight ){
    [self initWithNibName:@"LandscapeNib" bundle:nil];
}else if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
    [self initWithNibName:@"PortraitNib" bundle:nil];

}


return YES;
Run Code Online (Sandbox Code Playgroud)

}

但它没有改变Nib,它显示了初始加载的笔尖.我猜它是加载但没有显示,因为初始笔尖已经显示,不会被删除.我无法找到使用通用视图控制器处理多个笔尖的解决方案,以便我可以轻松处理控件的功能?

iphone orientation ipad

5
推荐指数
3
解决办法
4040
查看次数

标签 统计

iphone ×2

ipad ×1

iphone-sdk-3.0 ×1

nib ×1

orientation ×1

uiviewcontroller ×1

xib ×1