简体   繁体   中英

ios7: UIButton on UINavigationBar is not selectable

I have a pretty unique problem. I have a custom nav controller ( https://github.com/cwRichardKim/RKSwipeBetweenViewControllers ) and I'm trying to customize it even further. The effect I'm trying to get is this:

What I have is this (ignore the search bar):

The problem that I have is that when you click on any of the tabs in my nav bar ("public" for example), the click doesn't register, and it clicks whatever is underneath instead. For example, if I click "Munchies", it will click the search bar underneath the tab. Also, even if there is nothing clickable underneath it (I've tried this with a blank UIViewController), the tabs (eg: "Munchies") are still not clickable.

I have a theory for why this is. If I raise the tabs by a few pixels, the tops of the tabs become clickable. So, I think the navigationBar has a frame within which you can interact with its objects, but if you interact with anything outside of that frame, it interacts with lower layers. I've tried expanding the nav bar height and it doesn't work (I've looked it up and it's against the rules).

Any thoughts?

Thanks!

I read your code here that is shown here:

https://github.com/cwRichardKim/RKSwipeBetweenViewControllers/blob/master/RKSwipeBetweenViewControllers.m

I'm not exactly sure whether this will work out. But this issue has occured to me in table cell as well. Perhaps you can try typing this in.

[navigationView setUserInteractionEnabled:NO];

I'm pretty sure that your approach is on the right track because as I read Apple documentations it says:

Custom views can contain buttons. Use the buttonWithType: method in UIButton 
class to add buttons to your custom view in the style of the navigation bar. 
Custom title views are centered on the navigation bar and may be resized 
to fit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM