ViewControllerを持っていますが、TableViewを配置した中央に別の小さなUIViewを配置していますが、このテーブルの配列からデータを表示する方法がわからないと、感謝。私はこのコードを使用してテーブルをロードしようとしている:私はNSMutableArrayのをロードするために、私のテーブルビューにカスタムセルを使用していますUIViewで読み込むテーブルを取得できません
-(void) animateResults {
_resultsLabel.text = [NSString stringWithFormat:@"You Scored %d", runningScore ];
resultsTable.delegate = self;
resultsTable.dataSource = self;
[self.resultsTable registerClass:[resultsViewCell self] forCellReuseIdentifier:@"resultsListCell"];
[self.resultsTable reloadData];
[self.view layoutIfNeeded];
[UIView animateWithDuration:0.3 animations:^{
_resultsView.frame = self.view.frame;
} completion:^(BOOL finished){
NSLog(@"%@", questionsArray);
}];
}
。私は試しましたテーブルビューのこのコードを使用して:
-(NSInteger)numberOfSectionsInTableView:(resultsViewCell *)tableView {
//Return number of sections
return 1;
}
//get number of rows by counting number of challenges
-(NSInteger)tableView:(resultsViewCell *)tableView numberOfRowsInSection:(NSInteger)section {
return questionsArray.count;
}
//setup cells in tableView
-(resultsViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//setup cell
static NSString *CellIdentifier = @"resultsListCell";
resultsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSDictionary *results = [questionsArray objectAtIndex:indexPath.row];
NSString *resultsName = [results objectForKey:@"answers"];
BOOL correct = [[results objectForKey:@"correct"] boolValue];
if (!correct) {
cell.resultsIcon.image = [UIImage imageNamed:@"BlackIconLock.png"];
}
else{
cell.resultsIcon.image = nil;
}
cell.resultsName.text = resultsName;
return cell;
}
しかし、_resultsViewはなぜロードしないのですか?私はこれまでに多くの大きな助けを得ており、本当に感謝しています。私はこの時点で約2週間立ち往生してきた。助けてください!
'_resultView'が' nil'であることを確認してください。 – dasdom
申し訳ありませんが、私はこの学習の初心者です。どうすれば確認できますか?もう一度noobnessのために申し訳ありません – JoeShmoe
'NSLog(@" resultsView:%@ "、_resultsView)'行を 'animateResults'の先頭に追加し、アプリを実行してコンソール出力を見てください。 'resultsView :(null)'を出力すると、ビューはnilになります。 – dasdom