1

This is the code I'm using to present a modal view when the app first starts

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];


Security *security = [[Security alloc] initWithNibName:@"Security" bundle:nil];
[self.tabBarController.selectedViewController presentModalViewController:security animated:YES];
[security release];

return YES;

}

This is what the log says

Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x171320>.

Is there a better way to achieve this?

Also I have this method in my app delegate

    -(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

    if (viewController == [tabBarController.viewControllers objectAtIndex:2]) {

        //The Log Out tab locks the app by presenting a modalviewcontroller that can't be dismissed unless there is a password.
        Security *security = [[Security alloc] initWithNibName:@"Security" bundle:nil];
        [self.tabBarController presentModalViewController:security animated:YES];
        [security release];
        return NO;

    } else {

    return YES;
    }
}

Basically one of the options on my tabbarcontroller is a logout button. The above code works fine and doesn't throw a warning to the log.

Hackmodford
  • 3,901
  • 4
  • 35
  • 78

1 Answers1

0

Why are you presenting it from your tab bar controller? Assuming your above code is from a UIViewController, try

[self presentModalViewController:security animated:YES];

or

[self.navigationController presentModalViewController:security animated:YES];
Owen Hartnett
  • 5,925
  • 2
  • 19
  • 35
  • This is my app delegate. It's just NSObject that's why I was presenting from the tabbarcontroller – Hackmodford Dec 15 '11 at 15:16
  • Put up the viewController that's going to live under your modal, then use the above calls from that viewController to open the modal. then when you close the modal, the viewController will already be there running. – Owen Hartnett Dec 15 '11 at 15:24
  • So you're saying present this first view from one of the view controllers in the tabbarcontroller? – Hackmodford Dec 15 '11 at 15:27
  • 1
    Yes. Open a default view controller that would open if the modal were dismissed without choosing something from your tab bar, then open the modal. – Owen Hartnett Dec 16 '11 at 17:40
  • Yeah so basically this is how I did it. My app delegate has a bool called firstLaunch. applicationDidFinishLaunch... sets it to true. Then in my view controller (tab 1 view controller) on viewDidLoad it checks the appDelegate to see if (firstLaunch) is true and if so presents the modal view. and promptly sets it to false. The only problem with this method is the user gets to see what's behind the login screen for a second. But it works ;) – Hackmodford Dec 16 '11 at 18:47
  • Glad it works for you. Now you can credit me for the answer. – Owen Hartnett Dec 16 '11 at 21:47