Iphone 选项卡栏应用程序中的表视图

Iphone 选项卡栏应用程序中的表视图,iphone,ios,xcode,tableview,tabbar,Iphone,Ios,Xcode,Tableview,Tabbar,我已经找了好几个星期了,但没有找到一个Xcode 4的教程来展示如何将表视图添加到选项卡栏应用程序中。我想知道你是否能给我指出正确的方向 谢谢,任何TabBarController教程都应该这样做,因为您将UIViewController添加到了选项卡栏。对于表视图,只需创建UITableViewController。您应该能够将其添加到选项卡栏控制器。。。或任何其他视图控制器。例如,如果您发现其他教程正在使用navigationController执行选项卡栏。。。只需将教程中的navigat

我已经找了好几个星期了,但没有找到一个Xcode 4的教程来展示如何将表视图添加到选项卡栏应用程序中。我想知道你是否能给我指出正确的方向


谢谢,任何TabBarController教程都应该这样做,因为您将UIViewController添加到了选项卡栏。对于表视图,只需创建UITableViewController。您应该能够将其添加到选项卡栏控制器。。。或任何其他视图控制器。例如,如果您发现其他教程正在使用navigationController执行选项卡栏。。。只需将教程中的navigationController部分替换为UITableViewController即可。还有大量关于UITableViewController的文档和教程

例如,如果您在应用程序委托中查看此代码,则完成启动时使用了选项。为此,创建了MyTableViewController(UITableViewController)和其他一些UIViewController

// View Controllers for tabController - could be UItableViewControllers or any
// other UIViewController.  You will add this to the tabController
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];

MyTableViewController *myTable = [[MyTableViewController alloc] initWithNibName:@"MyTableViewController" bundle:nil];
[viewControllers addObject:myTable];

SomeOtherUIViewController *other = [[SomeOtherUIViewController alloc] initWithNibName:@"SomeOtherUIViewController" bundle:nil];
[viewControllers addObject:other];    

// add the UIViewControllers to the tabController
[tabController setViewControllers:viewControllers];

// add tabbar and show
[[self window] addSubview:[tabController view]];
[self.window makeKeyAndVisible];
return YES;
然后,在添加到选项卡栏的每个视图控制器中,确保在其init中将选项卡栏项添加到它们

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) 
    {
        UITabBarItem *barItem = [[UITabBarItem alloc] 
                             initWithTitle:@"Progress" 
                             image:[UIImage imageNamed:@"report.png"] tag:2];

        [self setTabBarItem:barItem];
        [barItem release];
    }
    return self;
}

它不是xcode4,但很有帮助: