2012-01-04 21 views
0

最初は、いいえ。セクション= 0といいえ。セクションの行数= 0データが利用可能な場合、いいえ。セクションの1と2への変更。セクション内の行は、私は、テーブルに行を挿入するために、上記のコードを使用しようとしました。1.insertRowsAtIndexPathsを使用する場合、空の配列の境界を超えるインデックス

NSArray *indexPathArray=[NSArray arrayWithObject:rowSectionIndexPath]; 
[tableView beginUpdates]; 
[tableView insertRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationFade]; 
[tableView endUpdates]; 

ずつ増加し続けます。しかし、エラーを受け取りました - [NSMutableArray objectAtIndex:]:空の配列の境界を超えてインデックス1。

私が行にデータを挿入し始めた行とセクションの値は、 行= 1とセクション= 1でした。 行= 2、セクション= 1; ....など。

必要なすべてのメソッドnumberOfSectionsInTableView、numberOfRowsInSection、cellForRowAtIndexPathおよびheightForRowAtIndexPathを使用していることを考慮して、コードには何がないのですか。

答えて

-1

[tableview reloadData] 

または

[tableView reloadSections:[NSIndexSet indexSetWithIndex:0]withRowAnimation:UITableViewRowAnimationRight]; 
0

はこれを試してみてください書いてください。それはあなたを助けるかもしれません。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
    { 
      return 1; 
    } 

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 


     return [displayWineList count];//pass your array count 
    } 
0

このようにしてみてください..、

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
    {    
     return 1;  
    } 

    - (NSInteger)tableView:(UITableView *)tableView 
     numberOfRowsInSection:(NSInteger)section 
    {   
     return [yourArray count]; 
    } 
0

行iが行にinsertingDataを起動した区間値、行= 1と区間= 1でした。行= 2およびセクション= 1; ....など。

行= 0から始めてみましたか? (英語の人ではないかもしれませんが、質問の最初の部分が私を混乱させます)

空のテーブルから始めれば、1を書き込む前に0を書き込む必要があるからです。

関連する問題