UIWebview 未显示在 UINavigationController 中
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我发现,我必须使用 viewDidLoad 中的框架来启动我的 web 视图:
ok, I found out, I had to initiate my webview with a frame in viewDidLoad: