私はiosの世界で初めてです。テーブルビューコントローラーにロードするデータがあり、それは完全にロードされます..新しい挿入が行われた場合、新しいデータはインデックス0から始まるNSMutableArrayに追加されます(新しいデータは一番上にありますNSMutableArray を新しいデータで更新した後、[tableview reloadData] と呼びます。
私の目的は、テーブルビューコントローラー(インデックス0)の上部に新しいデータを表示することですが、新しいデータは何もロードされていません! なぜ ?
これは、テーブル セルをロードするために使用するコードです。データは、オブジェクトを含む NSMutableArray です。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
NSString *identifier = [NSString stringWithFormat:@"cell%d", indexPath.row];
MyCell *cell = (MyCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[MyCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
// add description
UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(15,25, 260, 50)];
text.numberOfLines=3;
text.text= [[data objectAtIndex:indexPath.row] desc];
text.backgroundColor=[UIColor clearColor];
text.textAlignment= UITextAlignmentRight;
text.font = [UIFont fontWithName:@"Helvetica" size:13];
[cell addSubview:text];
}
//use your cell here
cell.textLabel.textAlignment=UITextAlignmentRight;
cell.textLabel.numberOfLines =3;
// cell font
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:13.0];
cell.textLabel.textColor=[UIColor blackColor];
return cell;
}