- (void)ItemPressed:(id)sender {
NSInteger index = [self.tabBarItems indexOfObject:sender];
BOOL shouldSelect = [self delegatedDecisionIfWeShouldSelectViewController:[self.viewControllers objectAtIndex:index] atIndex:index];
if (shouldSelect) {
if (index != self.selectedIndex) {
self.selectedIndex = index;
} else {
if ([self.selectedViewController isKindOfClass:[UINavigationController class]]) {
UINavigationController *navigationController = (UINavigationController *)self.selectedViewController;
[navigationController popToRootViewControllerAnimated:YES];
}
}
}
}
嗨,我创建了 tabbarcontroller 框架,使用源代码工作正常, 但创建的框架在选择一个索引到另一个时出错
-{WebDataSource indexof:]: unrecognized selector instance
我得到了上述错误。
有什么想法吗?
我声明了如下标签栏项目
vc1 = [[webviewname alloc] initUrl:[NSURL URLWithString:@"https://www.google.com"]];
vc2 = [[webviewname alloc] initUrl:[NSURL URLWithString:@"https://www.yahoo.com"]];
vc1.O_tabBarItem = [OTabBarItem itemWithTitle:@"index" image:[UIImage imageNamed:@"index"]];
vc2.O_tabBarItem = [OTabBarItem itemWithTitle:@"index" image:[UIImage imageNamed:@"index"]];
vc1.delegate=self;
vc2.delegate=self;
NSArray *vControl = [NSArray arrayWithObjects:vc1,vc2,nil];