0
 - (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];
4

1 回答 1

0

我希望你期望self.tabBarItems成为一个NSArray对象。但是在这里,对象引用了其他一些实例,比如 的实例WebDataSource

是否可以显示您如何声明和填充数组tabBarItems

于 2012-09-13T04:46:59.477 回答