0

システムUIBarButtonを作成したいのですが、プレーンなスタイルにしたいです。
このコードを試してみましたが、スタイルは無視されます。どうしたの?

UIBarButtonItem *search = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(showSearch)];    
search.style = UIBarButtonItemStylePlain;
self.navigationItem.rightBarButtonItem = search;
[search release];
4

2 に答える 2

2

The main thing here is that you need to place your button in the previous controller, not in the one that is going to be pushed.

//Your actual ViewController
UIBarButtonItem *search = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(showSearch)];    
search.style = UIBarButtonItemStylePlain;
self.navigationItem.rightBarButtonItem = search;
[search release];

//Controller that is going to be pushed and will display the new UIBarButtonItem
[self.navigationController pushViewController:newViewController animated:YES];
于 2011-09-09T02:12:19.443 に答える
0

ここに同様のスレッドが見つかりました。

この計画を立てる方法は、カスタム UIButton を作成し、それをバー ボタンに割り当てることのようです。

于 2011-09-08T16:24:37.753 に答える