2011-01-14 11 views
0

Hey!申し訳ありませんが、この質問が以前に尋ねられている場合は、私はGoogleのフォーラムを洗って、私は適切な答えを見つけることができませんでした。私はボタンが押されたときにだけデータを追加したいUITableViewを持っています。このボタンはカスタムボタンであり、通常の+ボタンではありません。どんな助けもありがとう!助けてくれるリンクがある場合は、投稿してください!ありがとうございました!ボタンが押されたときにUITableViewに行を追加する

答えて

0
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 

のUITableView Docs

+0

はあなたにTerenteをありがとうございます。だから私はIBでボタンを作成し、このメソッドに接続すると、私は行にテキストを追加できますか? – narda

0

からカスタムボタンを作成し、このメソッドにインターフェースビルダーでそれをフックアップ:

- (IBAction)buttonPressed:(id)sender{ 

    //Assuming you have an NSMutableArray named cellData 
    //as the datasource for your table: 

    //add to datasource 
    [[self cellData] addObject:[@"Cell " stringByAppendingFormat:@"%d", indexPath.row]]; 

    //add to table with a animation form the right 
    NSIndexPath *path = [NSIndexPath indexPathForRow:[[self cellData] count] - 1 inSection:0]; 
    NSMutableArray *rows = [NSMutableArray arrayWithObject:path]; 
    [[self tableView] insertRowsAtIndexPaths:rows withRowAnimation:UITableViewRowAnimationRight]; 

} 
関連する問題