UINavigationItem setHidesBackButton:YES won't prevent from going back

时间秒杀一切 提交于 2020-01-06 16:46:16

问题


It's odd, I know, but even if you stated hidesBackButton to YES for the UINavigationItem associated with your view, you will be able to go back just touching the area that was meant to be a back button.

Sharing my solution... (more to come)


回答1:


First I thought it was a simulator bug and uploaded to the device. But when I reproduced the same behavior there as well I started to think how to get rid of such behavior (since it was essential for me). Came up to such a solution:

[self.navigationItem setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithCustomView:[[UIView new] autorelease]] autorelease]];

And to show the back button again you write:

[self.navigationItem setLeftBarButtonItem:nil];

That's simple. Use it as a work-around, guys! Very strange this bug survived even in iPhone OS 3.0...




回答2:


i think hiding back bar button also work as

self.navigationItem.hidesBackButton = TRUE;



来源:https://stackoverflow.com/questions/1232557/uinavigationitem-sethidesbackbuttonyes-wont-prevent-from-going-back

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!