1

Heya, I have loaded a uiviewcontroller's view into the main window in the AppDelegate file. If i do it by loading a nib name (and create the UIViewController on the fly), the buttons in the xib file fire properly. If i do it like this, the buttons are inactive.

Happy to give more information, just unsure which info to give.

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

    launchScreen = [[LaunchScreen alloc] initWithNibName:nil bundle:nil];
    [launchScreen.view setUserInteractionEnabled:YES];
    [window addSubview:[launchScreen view]];
    [window makeKeyAndVisible];
    return YES;
}
4
  • What do you mean by "inactive"? Did you create the buttons programmatically in LaunchScreen (because otherwise there are no way to populate the view as you are not using the Nib file in the code)?
    – MHC
    Mar 10, 2011 at 0:52
  • Nope, the buttons are dropped in the view via Interface Builder, and then tied to functions in the LaunchScreen class. And by inactive, when you click (in the simulator) the buttons, they don't highlight or register against their functions. Mar 10, 2011 at 0:57
  • I see. I forgot the loadView logic searches for an Nib file with the same name with the view. That's strange because even if a target-action pair is not specified, the button is supposed to highlight when tapped, unless user interface is disabled. Mind giving some information on your Nib files?
    – MHC
    Mar 10, 2011 at 1:42
  • Really all I did was create a new UIViewController subclass (from the xcode 'new' menu), dragged two buttons onto the view area, and then dragged the touchinsideup(?) event to to IBActions within the m file for that xib. Absolutely nothing fancy at all there? Mar 10, 2011 at 1:46

1 Answer 1

0

Ok, I seem to have found the culprit, there was a ViewController in the main xib file that was being overlayed ontop of the buttons stopping them from being used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.