gpt4 book ai didi

iphone - UINavigationController 问题

转载 作者:行者123 更新时间:2023-12-01 19:26:06 25 4
gpt4 key购买 nike

我正在编写一个 iPad 应用程序。
在我的 UIViewController 类中,我正在处理一个按钮点击,通过它我正在显示另一个 View (UIWebView),方法是在 UINavigationController 中推送它。

问题是虽然我的 View 被插入 UINavigationController 并被显示,但我无法在导航栏中看到“后退”按钮。

我没有在我的 AppDelegate 中包含 UINavigationController 类,因为我试图从我的方法中直接使用 UINavigationController。下面是我的按钮点击处理代码:

NSString *url = [imageDict valueForKey:strName];
UINavigationController *navigation = [[UINavigationController alloc]init];
[navigation setNavigationBarHidden:NO];
[self.view addSubview:navigation.view];

CarouselWebView *carouselWebView = [[CarouselWebView alloc] initWithNibName:@"CarouselWebView" bundle:nil];
carouselWebView.urlString = url;
carouselWebView.title=@"Carousel Web View";
[navigation pushViewController:carouselWebView animated:YES];
[carouselWebView release];

请让我知道我在这里做错了什么。

谢谢,

最佳答案

您不会自动获得返回按钮,因为您的应用认为 carouselWebView 是导航 Controller 堆栈中的第一个 View 。

有两种方法可以处理此问题:

  • 先初始化导航 Controller ,在 carouselWebView 之前推送 View 。这不会在第一个 View 中显示导航栏上的任何按钮,但会在将 View 推到此初始 View 之上时显示“后退”按钮。
  • 您可以手动将后退按钮添加到 carouselWebView,并为其附加一个关闭该 View 的方法,因为导航 Controller 不会自动设置它。我不相信您可以手动将其设置为“箭头形”按钮,但您可以显示标有“返回”文本的默认按钮。
  • 关于iphone - UINavigationController 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7496457/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com