开发者

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

开发者 https://www.devze.com 2023-02-03 08:08 出处:网络
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 th

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

精彩评论

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