我设置了 4 个视图控制器,每个控制器都包含 aUIWebView
并将它们设置为 a 的选项卡UITabBarController
。
内容加载良好,按钮可点击,但内容UIWebViews
拒绝滚动。UIWebView
有一个内置UIScrollView
的来处理它自己的滚动,所以它应该滚动正确吗?
我在主文件中的初始化代码是:
tabBarController = [[MainTabBarController alloc] init];
[tabBarController.view setBounds:CGRectMake(0, 0, dev_portrait.size.width, 44)];
[tabBarController setDelegate:self];
UIImage* anImage = [UIImage imageNamed:@"53-house.png"];
UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Home" image:anImage tag:0];
WebViewController *vc1 = [[WebViewController alloc] initWithNibName:@"WebController" bundle:nil];
[vc1 setup];
[vc1 setTabBarItem:theItem];
/// ... same for the other 3 WebViewControllers
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, vc4, aNavigationController, nil];
tabBarController.viewControllers = controllers;
//self.window.rootViewController = tabBarController;
self.window.rootViewController = tabBarController;
当一个选项卡被触摸时,它会在视图控制器中触发一个加载 URL 的函数:
- (void)handleURL:(NSString *)url {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSLog(@"Handling URL: %@", request);
[webpage loadRequest:request];
lastURL = url;
[self startLoaderIndicator];
}