I am using XCode 4.2 to develop an application for iPhone and iPad
I am loading a view using the following function
-(IBAction)button{
...
SettingsView *hello ;
hello= [[SettingsView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:hello animated:YES];
}
on the simulator the view is loaded perfectly . but when I load the app on a real iPhone , I get a white screen and cannot go back to the app ... any reasons ?
The most common cause of this kind of problem is a case mismatch. since you passed nil
as the name, it'll try to load SettingsView.nib
. If your file is called Settingsview.nib
(note the "v"), then that will work on Mac (most of the time, and simulator) but not on iOS. By default, Mac has a case-insensitive filesystem. iOS always has a case-sensitive file system.
After you've built for device, go to ~/Library/Developer/Xcode/DerivedData
and find your project output. Dig down into the Products directory and make sure that your nib file is really there and named what you expect.
if no .xib is associated with it then use this code:
SettingsView *hello= [[SettingsView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:hello animated:YES];
[hello release];
if there is a .xib associated with it
SettingsView *hello= [[SettingsView alloc] initWithNibName:@"SettingsView" bundle:nil];
[self presentModalViewController:hello animated:YES];
[hello release];
try setting view frame
and modalPresentationStyle
SettingsView *hello= [[SettingsView alloc] initWithNibName:@"SettingsView" bundle:nil];
hello.view.frame = CGRectMake(<CGFloat x>, <CGFloat y>, <CGFloat width>, <CGFloat height>)
hello.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:hello animated:YES];
[hello release];
And from where (what is self??) are you trying to present a modalviewcontroller??
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.