开发者

iPhone/iPad: how to change location of home or cancel or any buttons in UINavigationController (with or without InterfaceBuilder)

开发者 https://www.devze.com 2023-02-05 20:23 出处:网络
My question is fairly straightforward and simple. I have seen code that implements a button (such as a cancel button) that can be added to a UINavigationController. Code looks like this:

My question is fairly straightforward and simple.

I have seen code that implements a button (such as a cancel button) that can be added to a UINavigationController. Code looks like this:

UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] 
        initWithImage: [UIImage imageNamed:@"home.png"] 
        style: UIBarButtonItemStylePlain target: self 
        action: @selector(cancel:)];

self.navigationItem.rightBarButtonItem = cancelButton;
[cancelButton release];

What I'd like to do is to place these buttons in a custom location in the navigationItem...not in the default rightBarButtonItem or leftBarButtonItem location, but controllable perhaps using x and y co-ordinates...is this even possible? It seems like a simple request, but google searching and documentation reviewing is driving me a little nuts :)

开发者_如何学C

I would appreciate any assistance with this issue.

thanks again,

Edward


I agree with 'Hack Saw' in the case of it being against the Apple 'Human Interface Guide' and thus not recommended...However... If you want to, you can draw additional views into the navigation bar's title view [self.navigationContoller.navigationBar.topItem setTitleView]. Hope that helps!

Here is link to reference: UINavigationItem


They don't make that easy because it would break user expectation. I recommend against it. If you have a serious need for it, you'll probably need to make your own navbar.

0

精彩评论

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