简体   繁体   English

iPhone:导航栏“返回”按钮可点击=否?

[英]iPhone:navigation bar “back” button clickable = NO?

I know that we can hide navigation bar "back" button.我知道我们可以隐藏导航栏的“返回”按钮。 But I dont whant to hide it?但我不想隐藏它? Is there any way to make it just not clickable ?有什么办法让它不能点击吗?

You can not disable the backBarButtonItem .您不能禁用backBarButtonItem Setting enabled property of backBarButtonItem to NO doesn't actually disables it.backBarButtonItemenabled属性设置为NO实际上不会禁用它。

It seems Apple prevented others("us") from disabling backBarButtonItem , even it ignores the target and action set to backBarButtonItem .似乎 Apple 阻止了其他人(“我们”)禁用backBarButtonItem ,即使它忽略了设置为backBarButtonItem目标操作

try this尝试这个

    self.navigationItem.leftBarButtonItem.enabled=NO;

    self.navigationItem.backBarButtonItem.enabled=NO;

Update:更新:

It seems to be Apple doesn't allow the back button to enable / disable.似乎Apple不允许启用/禁用后退按钮。 Instead of that we can hide it.取而代之的是,我们可以隐藏它。

    self.navigationItem.hidesBackButton = YES;
self.navigationItem.backBarButtonItem.enabled = NO;

Disable:禁用:

self.navigationItem.leftBarButtonItem.enabled = NO;

Enable:使能够:

self.navigationItem.backBarButtonItem.enabled = YES;

The default cancel button cannot be disabled as Apple does not allow this feature.无法禁用默认取消按钮,因为 Apple 不允许此功能。

This doesn't work with the default back button.but it's possible to hide the default back button [self.navigationItem setHidesBackButton:YES];这不适用于默认的后退按钮。但是可以隐藏默认的后退按钮[self.navigationItem setHidesBackButton:YES];

Apple does not want you to disable it but you can hide it of course. Apple 不希望您禁用它,但您当然可以隐藏它。

self.navigationItem.hidesBackButton = YES;

This especially works well if you have a custom UIBarButtonItem as a button.如果您有一个自定义 UIBarButtonItem 作为按钮,这尤其适用。

In stock applications you would notice features that are not applicable are hidden altogether rather than disabled.在库存应用程序中,您会注意到不适用的功能完全隐藏而不是禁用。

Yes, you can disable that button, just setenabled property of that button to NO.是的,您可以禁用该按钮,只需将该按钮的启用属性设置为 NO。

Should be possible to disable the button:应该可以禁用按钮:

backButton.enabled = NO;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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