2016-05-14 5 views
0

私は奇妙なエラーがあります。私はUITableViewを使用しています。これは、行が選択されたときにリロードする必要があります。これはiPhoneのシミュレータでうまく動作します。 iPadで実行中、didSelectRowAtIndexPathが呼び出されていますが、UIが更新されていません。 メインスレッドでメソッドreloadDataを呼び出してみました。それはまだ同じです。TableView reloadDataはiPadのUIを更新しませんが、iPhoneで動作します

私はさまざまなソリューションをstackoverflowで試してみました。何も私の問題を修正するように見えませんでした。

UPDATE

私は、セルを選択すると、新しいセルが追加されます。だから私はテーブルビューを動的に変更を表示するためにリロードする必要があります。 は、あなたがテーブルビューの選択デリゲートメソッドでは、テーブルビューのデリゲート内のテーブルビューをリロードしている

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath 
{ 
NSUInteger count=indexPath.row+1; 

NSMutableArray *insertIndexPaths = [NSMutableArray array]; 

[insertIndexPaths addObject:[NSIndexPath indexPathForRow:count inSection:indexPath.section]]; 

switch (indexPath.row) { 
     case 0: 
    { 
    if ([ItemsInSection[indexPath.section] count]==1){ 
       [ItemsInSection[indexPath.section] addObject:obj2]; 

       [TabView beginUpdates]; 
       [TabView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft]; 

       [TabView endUpdates];   
      } 
      else { 

       [ItemsInSection[indexPath.section] removeAllObjects]; 
       [ItemsInSection[indexPath.section] addObject:obj1]; 

       [self.TabView reloadData]; 

      } 
     } 
      break; 

     case 1: 

    {if ([ItemsInSection[indexPath.section] count]==2){ 
       [ItemsInSection[indexPath.section] addObject:obj3]; 

       [self.TabView beginUpdates]; 
       [TabView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft]; 
       [self.TabView endUpdates]; 

      } 
      else 
      { 
       [ItemsInSection[indexPath.section] removeAllObjects]; 
       [ItemsInSection[indexPath.section] addObject:obj1]; 
       [ItemsInSection[indexPath.section] addObject:obj2]; 

       [self.TabView reloadData]; 
       } 
     } 
      break; 

     case 2: { 

      if ([ItemsInSection[indexPath.section] count]==3) { 
       [ItemsInSection[indexPath.section] addObject:obj4]; 
       [self.TabView beginUpdates]; 
       [TabView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft]; 
       [self.TabView endUpdates]; 

      } 
      else 
      { 
       [ItemsInSection[indexPath.section] removeObject:obj4]; 
       [self.TabView beginUpdates]; 
       [TabView deleteRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationLeft]; 

       [self.TabView endUpdates]; 

      } 
      } 
      break; 

        default: 
      break; 
    } 

} 
+2

コードを投稿する必要があります。それは私には問題はどこかにあると思う。また、セルを選択したときにテーブルビュー全体をリロードする理由は何ですか?あなたの努力がうまくいかないような解決策を探すのではなく、実際に達成しようとしている目標を記述してください。 – ozgur

答えて

0

この問題の解決策を見つけました。 UITableViewCellの背景色はクリアカラーに設定され、UITableViewCell上のUIViewの背景色もクリアカラーに設定されています。これらの設定を変更すると、iPadシミュレータのUITableViewに行が挿入されました。

2

以下の私のコードを投稿彼らの関連する選択アニメーションプロセスを持っています。そこで、このメソッド内のすべてのコードを別のメソッドに移動することをお勧めします。そのメソッドを呼び出します。

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(),^{ 
      [self.aiTableView beginUpdates]; 
      // your table view selection code 
      [self.aiTableView endUpdates]; 
    }); 
+0

これは私の問題を解決しません。 NumberOfRowsInSectionメソッドは、行数を返しません。しかし、それはUITableViewに挿入されていません。これはiPadでのみ発生します。私のオリジナルコードはiPhoneでうまくいきます。私は問題が何であるか疑問に思っています – user5553647

+0

私のすべてのコードをdispatch_after()からdispatch_async(dispatch_get_main_queue()、^ {})に移動してみてください。 、あなたがテーブルビューのデリゲート選択メソッドのコードのこのブロックを呼び出している時間を確認してください。 – kaushal

+0

iPhoneとiPadでコードの動作が不安です。 :) – kaushal

関連する問題