簡體   English   中英

將數據添加到UITableView時iPhone App崩潰

[英]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符合UITableViewDataSourceUITableViewDelegate 另外,您MyFileTableController我假設是UIViewController (基於名稱的MyFileTableController )添加到視圖層次結構(需要UIView )。 如果需要顯示MyFileTableController ,則需要以模態或通過其他方式(例如UINavigationController

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM