2011-02-07 9 views
0

プログラムで作成されたUIViewControllerがあります。 loadViewに次のコードを追加します。ツールバーが表示されますが、追加したボタンは表示されません。どんな助けでもご賞味いただけます。loadViewでUIToolBarアイテムが追加されない

[self.navigationController setToolbarHidden:NO animated:NO]; 

    UIBarButtonItem *actionB = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(actionBTapped:)]; 
    [self.navigationController.toolbar setItems:[NSArray arrayWithObject:actionB] animated:NO]; 
    [actionB release]; 

答えて

3

は、あなたがのUIViewController自体に項目を設定する必要はなく、そのナビゲーションコントローラ:

self.toolbarItems = [NSArray arrayWithObject:actionB]; 
1

これを試してみてください:

NSMutableArray *items = [[[NSMutableArray alloc] init] autorelease]; 
UIBarButtonItem *labelButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil] autorelease]; 
[items addObject:labelButton]; 
[items addObject:[[[UIBarButtonItem alloc] initWithTitle:@"YoutTitle" style:UIBarButtonItemStyleDone target:self action:@selector(actionBTapped:)] autorelease]]; 
[self.navigationController.toolbar setItems:items animated:NO]; 
関連する問題