在模拟器上运行ios4.2 app是可以的,在设备上,NIB视图为空

时间:2011-02-09 17:54:57

标签: iphone xcode ios

我在xcode 3.2.5中开发了一款iphone应用程序。如您所知,此版本的xcode仅附带4.2的sdk。在测试应用程序时,我将活动可执行文件设置为iPad模拟器3.2。当运行此可执行文件时,应用程序中的一个视图完全空白(白色),但UINavigationController导航栏仍然可见。

此空白视图恰好是从NIB文件加载的唯一视图,其他(工作)视图都是以编程方式生成的。

我在构建设置中将IOS部署目标设置为ios 3.2。

我的问题有什么理由吗?我的观点非常简单,有几个按钮,标签和UIWebView。

编辑:视图是在IB中构建的。 FWIW在视图中还有一些图像

更新:自从我在设备上运行应用程序(iPad 4.2和iPhone 3.1)后出现同样的问题,这个特殊的视图显示为白色。

回应评论; 在IB中,我将File's Owner的类设置为我的视图控制器,然后通过将'dot'连接到UIScrollView将viewcontroller的视图设置为根视图(在本例中为UIScrollView)。

我没有视图控制器的init方法,下面是viewdidload方法。

- (void)viewDidLoad{
[super viewDidLoad];

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];
self.navigationItem.rightBarButtonItem = addButton;
self.navigationItem.title=[programme CAOCode];
[addButton release];



NSMutableString *subTitle=[NSMutableString  stringWithString:[programme CAOCode]];
[subTitle appendString:@" "];
[subTitle appendString:[programme AwardType]];
[subTitle appendString:@" in"];

[subtitle setText:subTitle];
[maintitle setText:[programme Title]];



btnCurrentTab=aboutThisProgramme; // this is startup active tab


[details loadHTMLString:[self GetOverViewHTML]  baseURL:[NSURL fileURLWithPath:  [[NSBundle mainBundle] bundlePath]]];


}

最后,这是实例化有问题的控制器(来自tableviewcontroller)的代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

// Create and push a detail view controller.
ProgrammeViewController *programmeViewController = [ProgrammeViewController alloc];
Programme *selectedProg = (Programme *)[[self fetchedResultsController] objectAtIndexPath:indexPath];

// Pass the selected course to the new view controller.
programmeViewController.programme = selectedProg;

[self.navigationController pushViewController:programmeViewController animated:YES];
[programmeViewController release];
}

1 个答案:

答案 0 :(得分:1)

问题出在

ProgrammeViewController *programmeViewController = 
  [ProgrammeViewController alloc];

如果从NIB文件加载它,它应该类似于

ProgrammeViewController *programmeViewController = 
  [[ProgrammeViewController alloc] initWithNibName:@"MyNibName" bundle:nil];

“MyNibName”应该是没有.xib文件扩展名的nib的文件名。 确保nib文件包含在构建中。

相关问题