Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newlearner

macrumors member
Original poster
Jul 30, 2009
37
0
india
Hello

I have an app with two views. Suppose viewcontroller A and viewcontroller B. In iPhone 3G, app launches with View A and then after a delay of 3 seconds, view B comes up.

But in iPhone 4, app always launches with view B.

I have set the UIApplicationExitsOnSuspend to YES for always starting from view A.

But view A never shows up in iPhone 4.

On simulator everything works fine.This behavior on the device has been noticed during testing via ad-hoc distribution. Hence I am unable to debug it.

Here is the code:

In the appDelegate implementation, am calling the first view as:
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
[[UIApplication sharedApplication] setStatusBarHidden:YES
                                        withAnimation:UIStatusBarStyleDefault];

ViewControllerA *avc=[[ViewControllerA alloc]initWithNibName:@"ViewControllerA" bundle:nil];

[window addSubview:avc.view];
[window makeKeyAndVisible];
return YES;
}

view did load of ViewControllerA:

Code:
 - (void)viewDidLoad {
          [NSThread sleepForTimeInterval:3.5];
          viewControllerB *bvc=[[viewControllerB  alloc]initWithNibName:@"viewControllerB"                                                         bundle:nil];

[self.view addSubview:bvc.view];
[super viewDidLoad];
}

Using IB in viewControllerA.xib, I have put up an UIImageView.

Whenever the app loads up in the device, instead of viewControllerA, always viewControllerB shows up.

Thanks
 
Where you do that NSThread sleep: don't ever do that. You are sleeping the main thread of the application making it totally unresponsive. You are lucky that iOS is not killing your app for taking to long to start up. Use an NSTimer instead.
 
@robbieduncan: thanks, your tip worked like a charm. NSThread was the one posing the issue.

@dejo: the splash screen is different. viewControllerA contains an image which serves as an instruction to use the app.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.