简体   繁体   中英

BarButton wont appear in navigation menu Objective -C

Story:

I try to create a easy Login app (the username and pw are saved in the SQlite db) i have 3 properties two Labels and a BarButton . the labels are working but the BarButton wont appear i really dont know why .. i tried it several-times but somehow i cant find my error im using Xcode 4.5.2 /developing on iPhone SDK 6.0 /Master-Detail Application Layout , im not using the Storyboard im using a Xib-File .

-(void) keyboardAppearance{
    if(isKeyboardVisible == FALSE){
        isKeyboardVisible = true;
        UIBarButtonItem *btnGo = [[UIBarButtonItem alloc]initWithTitle:@"Login" style:UIBarButtonItemStyleBordered target:self action:@selector(loginAction)];
        self.navigationItem.rightBarButtonItem = btnGo;
    }
}

Any help appreciated

My guess is that self.navigationItem is nil, which would mean that your UIViewController is not contained within a UINavigationController. For this to work you need to do something like this:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myController];

Then present the "navController" instead of "myController".

Hope that helps.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM