- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MainViewController *rootViewController = [[MainViewController alloc] init]; _naviControl = [[UINavigationController alloc]initWithRootViewController:rootViewController]; self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; [self.window addSubview:_naviControl.view]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
在我的AppDelegate
..!
连接到MainViewController.m
答案 0 :(得分:0)
AppDelegate不是UIViewController,因此将UITableView连接到它与MVC原则冲突,如下所述:https://developer.apple.com/library/ios/documentation/general/conceptual/devpedia-cocoacore/MVC.html
你想要做的是让你的MainViewController的视图有一个tableView作为子视图
这样的事情: (在MainViewController.m中)
- (void)viewDidLoad {
[super viewDidLoad];
self.feedTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.feedTableView.dataSource = self;
self.feedTableView.delegate = self;
[self.view addSubview:self.feedTableView];
}