开发者

iPhone - Creating a simple UINavigationBar with a Back button using Interface Builder

No complex things here. I've added in my xib a navigationBar, and I'd like to add a "back" button on its left. But nothing works. I've added "many" other buttons, but I can't achieve adding this one...

Do you开发者_JS百科 know how I may do ?


You can either add text or a small image for the back button.

In the viewDidLoad scope, add:

/*  add an image  */
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
[backButton setImage:[UIImage imageNamed:@"back.png"]];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];

/*  add text  */
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
[backButton setText:@"Back"];;
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜