このトピックに関する多くの記事を読んでいますが、私の問題を解決するための回答が見つかりません...その理由から、助けてください:tableview reloadDataが機能しません... - NSArray invalid summary
私はSplitViewControllerテンプレートを持つiPadアプリを持っています。したがって、RootViewControllerはUITableViewControllerの型です。私のデータは2つの配列に格納され、XMLParser(クラスSyncController)で埋められます。しかし、のtableViewは...データは表示されません
まずAppDelegateでパーサの私の呼び出し:作品
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the split view controller's view to the window and display.
self.window.rootViewController = self.splitViewController;
[self.window makeKeyAndVisible];
syncController = [[SyncController alloc] init];
[syncController syncData];
return YES;
}
。私は私のRootViewControllerに転送したい、SyncControllerは、XMLを解析していると最後に、私は私のデータで埋めSyncControllerの2つのインスタンス変数(NSMutableArrays)を持っている:
rootViewController.visitorNames = [[NSArray alloc] initWithArray:self.visitorNames];
rootViewController.visitorCompanies = [[NSArray alloc] initWithArray:self.visitorCompanies];
[rootViewController.tableView reloadData];
reloadDataが動作しているようです:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"comp count: %u", [self.visitorCompanies count]);
return [self.visitorCompanies count]; }
。コンソールは ...要素の右の数を示ししかし、その後、cellForRowAtIndexPathが
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"testghjgjggjgjggjghjghjghjghjghjghjjhgghj");
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = [self.visitorCompanies objectAtIndex:indexPath.row];
return cell;
}
THERと呼ばれていませんeはコンソール出力ではありません。 は、だから私は、インスタンス変数
を見てnumberOfRowsInSectionにブレークポイントを設定した彼らはOKのように見えるが、あなたはのtableViewの_dataSourceを見たとき、あなたは無効な要約があることがわかり...
なぜ私のTableViewが機能しないのかと思います。
情報:あなたはSyncController
を介してデータをロードしないとき、それは正常に動作として、私はSyncControllerを使用し、RootViewControllerののviewDidLoadで固定値でNSArraysを初期化していない場合は、それが正常に動作します
不足しているプロパティrootViewControllerが解決策でした。 syncController.rootViewController = selfです。rootViewController < - 働いた!ありがとうございました! – Mceee