简体   繁体   中英

running ios4.2 app on on simulator is OK, on devices, a NIB view is blank

I developed an iphone app in xcode 3.2.5. As you know this version of xcode only comes with sdk for 4.2. While testing the app, I set the active executable to iPad simulator 3.2., when this executable is run, one of the views in the app in completely blank (white), the UINavigationController nav bar is still visible though.

This blank view happens to be the only one loaded from a NIB file, the other (working) views are all programmatically generated.

I set the IOS deployment target to be ios 3.2 in the build settings.

Is there any reason for my problem? My view is fairly simple, a few buttons, labels and a UIWebView.

Edit: the view was constructed in IB. FWIW there are a handful of images in the view also

Update: I've since run the app on devices (iPad 4.2 & iPhone 3.1) with the same problem, this particular view appears all white.

In response to comments; In IB I set the File's Owner's class to be my view controller then set the viewcontroller's view to be the root view (in this case a UIScrollView) by connecting the 'dot' to the UIScrollView.

I don't have an init method for the view controller, below is the viewdidload method.

- (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]]];


}

Finally, this is the code which instantiates the problematic controller (from a 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];
}

The problem is in the line

ProgrammeViewController *programmeViewController = 
  [ProgrammeViewController alloc];

If you are loading it from a NIB file it should be something like

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

"MyNibName" should be the file name of the nib without the .xib file extension. Make sure of course that the nib file is included in the build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM