UIWebview 未显示在 UINavigationController 中

发布于 2024-08-30 12:19:55 字数 1614 浏览 1 评论 0原文

我有一个 tabBar 应用程序。在第一个选项卡中,我有一个导航栏。在此导航栏中,我有一个表格视图。当用户单击表格的单元格时,它会转到另一个表格视图,当用户单击该表格中的单元格时,它会转到 webview 以打开网页。

基本上,在打开网络视图之前一切都很好。在 web 视图中, viewDidLoad 被调用并且似乎工作正常。但是,webViewDidStartLoad 永远不会被调用,网页也永远不会显示。

我没有使用IB。我在 AppDelegate 中构建 UITabBarController,同时为每个选项卡分配一个 UINavigationController 实例。

我从第二个 UITableViewController 调用 webview,如下所示:

rssWebViewController = [[webViews objectAtIndex: indexPath.row] objectForKey:@"controller"];
[[self navigationController] pushViewController:rssWebViewController animated:YES];

我已经检查了 navigationController 是否在那里,看起来很好。

我的 web 视图的 viewDidload 如下:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *urlAddress = self.storyUrl;
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [[self rssWebView] setDelegate: self];
    [[self view] addSubview:[self rssWebView]];
    [rssWebView loadRequest:requestObj];
    self.rssWebView.scalesPageToFit = YES; 
    self.rssWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    }

web 视图控制器接口定义如下:

@interface RSSWebViewController : UIViewController <UIWebViewDelegate>{
    IBOutlet UIWebView *rssWebView;
    IBOutlet NSString *storyUrl;
    IBOutlet NSString *feedName;
}
@property (nonatomic, retain) IBOutlet UIWebView *rssWebView;
@property (nonatomic, retain) IBOutlet NSString *storyUrl;
@property (nonatomic, retain) IBOutlet NSString *feedName;
@end

非常感谢任何帮助。

I have a tabBar application. In the first tab, I have a navigation bar. In this navigation bar I have a table view. When the user clicks a cell of the table, it goes to another table view, and when the user clicks a cell in that table, it goes to a webview to open a web page.

Basically, it goes fine until opening the webview. In the webview, viewDidLoad is called and seems to work properly. However, webViewDidStartLoad is never called and the web page never shows up.

I am not using IB. I build the UITabBarController in the AppDelegate, where I also assign an instance of my UINavigationController for each tab.

I call the webview from the second UITableViewController as follows:

rssWebViewController = [[webViews objectAtIndex: indexPath.row] objectForKey:@"controller"];
[[self navigationController] pushViewController:rssWebViewController animated:YES];

I have checked that the navigationController is there and it seems just fine.

The viewDidload of my webview is as follows:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *urlAddress = self.storyUrl;
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [[self rssWebView] setDelegate: self];
    [[self view] addSubview:[self rssWebView]];
    [rssWebView loadRequest:requestObj];
    self.rssWebView.scalesPageToFit = YES; 
    self.rssWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    }

The web view controller interface is defined as follows:

@interface RSSWebViewController : UIViewController <UIWebViewDelegate>{
    IBOutlet UIWebView *rssWebView;
    IBOutlet NSString *storyUrl;
    IBOutlet NSString *feedName;
}
@property (nonatomic, retain) IBOutlet UIWebView *rssWebView;
@property (nonatomic, retain) IBOutlet NSString *storyUrl;
@property (nonatomic, retain) IBOutlet NSString *feedName;
@end

Any help is greatly appreciated.

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

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

发布评论

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

评论(1

思慕 2024-09-06 12:19:55

好吧,我发现,我必须使用 viewDidLoad 中的框架来启动我的 web 视图:

rssWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];

ok, I found out, I had to initiate my webview with a frame in viewDidLoad:

rssWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文