[英]iPhone App Crashes when adding data to UITableView
我正在制作一個應用程序,但是當我嘗試向表視圖添加數據時,我的應用程序掛在這里:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate class]));
這是我的代碼:
UITableView *fileTable = [[UITableView alloc] initWithFrame:CGRectMake(10, 46, 300, 369) style:UITableViewStylePlain];
[fileTable setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Canvas_Tile.png"]]];
[fileTable setDelegate:self];
MyFileTableController *cont = [[MyFileTableController alloc] init];
[fileTable setDataSource:cont];
[self.view addSubview:fileTable];
是的,我包括UITableViewDelegate,包括我的應用程序委托在內的所有類都很好。 當我刪除“ [fileTable setDataSource:cont];”時,它不會崩潰。
確保MyFileTableController
符合UITableViewDataSource
和UITableViewDelegate
。 另外,您MyFileTableController
我假設是UIViewController
(基於名稱的MyFileTableController
)添加到視圖層次結構(需要UIView
)。 如果需要顯示MyFileTableController
,則需要以模態或通過其他方式(例如UINavigationController
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.