Xcode iPhone 后退按钮

发布于 2024-12-05 16:12:19 字数 188 浏览 1 评论 0原文

看起来这很简单,但我找不到任何好的信息。

我只是希望能够“强制”显示后退按钮。我有一个主视图,当我转移到另一个视图时没有后退按钮。但是,如果我转移到第三个视图,则会出现后退按钮。情况似乎总是如此。只有第二个转移到视图显示后退按钮。我需要它显示在除主视图之外的所有视图上。

我不需要覆盖它,只需强制它显示它没有显示的地方......

Seems like this would be a simple thing, but I cannot find any good info on it.

I just want to be able to 'force' the back button to show. I have a main view and when I transfer to another view there is no back button. But then if I transfer to a 3rd view, the back button appears. This seems to always be the case. Only the 2nd transferred to view shows a back button. I need it to show up on all views except the main view.

I dont need to override it, just simply force it to show where it is not showing...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

能否归途做我良人 2024-12-12 16:12:19

我知道这是一个老问题,但这可能会有所帮助......

有时您需要在导航控制器中嵌入一个视图以显示后退按钮。只需选择您的视图控制器并选择编辑器 ->嵌入 ->导航控制器。

如果按钮没有显示(通常如果您呈现的是模态视图而不是推送),那么您将需要手动创建“取消”按钮。为此创建一个操作并在 put 方法中(我将其称为我的方法 switchback):

-(IBAction)switchback:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

I know this is an old question, but this might help...

...sometimes you need to embed a view inside a Navigation Controller for the back button to show. Simply select your view controller and select Editor -> Embed In -> Navigation Controller.

If the button does not show (usually if you are presenting a modal view rather than push) then you will need to manually make a 'Cancel' button. Create an action for this and in the method put (I call my method switchback):

-(IBAction)switchback:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}
三寸金莲 2024-12-12 16:12:19

不幸的是,补丁的解决方案(dismissModalViewController)已被弃用并被dismissViewControllerAnimated取代。
这是当前的:

-(IBAction)switchback:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

Patch's solution (dismissModalViewController)had been unfortunately deprecated and replaced by dismissViewControllerAnimated.
Here is the current one:

-(IBAction)switchback:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文