user1051935
user1051935

Reputation: 589

objective C view is not being loaded on physical device

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 ?

Upvotes: 1

Views: 96

Answers (3)

Frade
Frade

Reputation: 2988

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??

Upvotes: 0

Rob Napier
Rob Napier

Reputation: 299265

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.

Upvotes: 2

shabbirv
shabbirv

Reputation: 9098

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

Upvotes: 1

Related Questions