UIBarButtonItem未显示

时间:2011-08-31 21:40:41

标签: iphone objective-c uibarbuttonitem

我无法显示我的UIBarButtonItem。我尽可能地简化了它,但即使这样也没有显示条:

- (void)viewDidLoad {
    UIBarButtonItem *supprBouton =[[UIBarButtonItem alloc]
                                   initWithTitle:@"Supprimer"
                                   style:UIBarButtonItemStyleBordered
                                   target:self
                                   action:@selector(supprimerDate:)];
    self.navigationItem.rightBarButtonItem = supprBouton;

    UIBarButtonItem *enregBouton = [[UIBarButtonItem alloc]
                                    initWithTitle:@"Enregistrer"
                                    style:UIBarButtonItemStyleBordered
                                    target:self
                                    action:@selector(enregFichier:)];
    self.navigationItem.leftBarButtonItem = enregBouton;
    [enregBouton release];
    [supprBouton release];
}

一个右键,一个左键,这应该至少显示,不是吗?什么可能是错的?

2 个答案:

答案 0 :(得分:1)

如果没有更多背景信息,我最好的猜测是您还没有设置UINavigationController

答案 1 :(得分:0)

尝试在您的视图中添加uinavigationcontroller:

UIViewController *vc = [[UIViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navCntrl1 = [[UINavigationController alloc] initWithRootViewController:vc];