2016-08-29 10 views
0

私はアプリのデバッグに取り組んでいますが、不具合があります。私はアプリやインターネット上でそれを見つけましたが、何も見つかりませんでした。iOSアプリケーションの不具合

あなたはそれがその短い時間間隔については、以下のようになります。enter image description here

以下

からグリッチに到達することができます。

enter image description here

マイコード:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
if (indexPath.item == 0) { 
    HGOtherUserTopInformationCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForTopInfoCellProfile forIndexPath:indexPath]; 
    cell.user = [HGUser currentUser]; 
    cell.amIFollowing = false; 
    cell.delegate = self; 
    cell.viewController = self; 
    return cell; 
}else{ 
    if (indexPath.item % 2 != 0) { 
     HGSeperatorCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForSeperatorCellProfile forIndexPath:indexPath]; 
     cell.backgroundColor = [UIColor lightGrayColor]; 
     return cell; 
    }else{ 
     HGActivity * activity = self.profileActivities[(indexPath.item - 2)/2]; 
     if ([activity.activityType isEqualToString:kActivityKeyUserPublishedResponse]) { 
      // Response 
      HGResponse * response = activity.response; 
      if ([response.mediaType isEqualToString:@"Photo"]) { 
       HGOtherUserPhotoCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForPhotoCellProfile forIndexPath:indexPath]; 
       cell.response = response; 
       cell.indexPath = indexPath; 
       cell.baseDelegate = self; 
       if (userLikedResponses) { 
        if ([userLikedResponses containsObject:response.objectId]) { 
         cell.liked = true; 
        }else{ 
         cell.liked = false; 
        } 
       } 
       cell.viewController = self; 
       if (joinedChallenges) { 
        bool joined = false; 
        for (HGActivity * joinedChallengeActivity in joinedChallenges) { 
         if ([joinedChallengeActivity.challenge.objectId isEqualToString:response.challenge.objectId]) { 
          joined = true; 
          break; 
         } 
        } 
        cell.joined = joined; 
       }else{ 
        cell.joined = false; 
       } 
       return cell; 
      }else if ([response.mediaType isEqualToString:@"Video"]) { 
       HGOtherUserVideoCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForVideoCellProfile forIndexPath:indexPath]; 
       cell.response = response; 
       cell.indexPath = indexPath; 
       cell.baseDelegate = self; 
       if (userLikedResponses) { 
        if ([userLikedResponses containsObject:response.objectId]) { 
         cell.liked = true; 
        }else{ 
         cell.liked = false; 
        } 
       } 
       if (indexPath.item == 2) { 
        [cell playMuted]; 
       } 
       cell.viewController = self; 
       if (joinedChallenges) { 
        bool joined = false; 
        for (HGActivity * joinedChallengeActivity in joinedChallenges) { 
         if ([joinedChallengeActivity.challenge.objectId isEqualToString:response.challenge.objectId]) { 
          joined = true; 
          break; 
         } 
        } 
        cell.joined = joined; 
       }else{ 
        cell.joined = false; 
       } 
       return cell; 
      }else{ 
       HGOtherUserMedialessCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForMedialessCellProfile forIndexPath:indexPath]; 
       cell.response = response; 
       cell.indexPath = indexPath; 
       cell.baseDelegate = self; 
       if (userLikedResponses) { 
        if ([userLikedResponses containsObject:response.objectId]) { 
         cell.liked = true; 
        }else{ 
         cell.liked = false; 
        } 
       } 
       cell.viewController = self; 
       if (joinedChallenges) { 
        bool joined = false; 
        for (HGActivity * joinedChallengeActivity in joinedChallenges) { 
         if ([joinedChallengeActivity.challenge.objectId isEqualToString:response.challenge.objectId]) { 
          joined = true; 
          break; 
         } 
        } 
        cell.joined = joined; 
       }else{ 
        cell.joined = false; 
       } 
       return cell; 
      } 
     }else{ 
      // Challenge 
      HGChallenge * challenge = activity.challenge; 
      if ([challenge.mediaType isEqualToString:@"Photo"]) { 
       HGOtherUserPhotoCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForPhotoCellProfile forIndexPath:indexPath]; 
       cell.challenge = challenge; 
       cell.indexPath = indexPath; 
       cell.baseDelegate = self; 
       if (userLikedChallenges) { 
        if ([userLikedChallenges containsObject:challenge.objectId]) { 
         cell.liked = true; 
        }else{ 
         cell.liked = false; 
        } 
       } 
       cell.viewController = self; 
       if (joinedChallenges) { 
        bool joined = false; 
        for (HGActivity * joinedChallengeActivity in joinedChallenges) { 
         if ([joinedChallengeActivity.challenge.objectId isEqualToString:challenge.objectId]) { 
          joined = true; 
          break; 
         } 
        } 
        cell.joined = joined; 
       }else{ 
        cell.joined = false; 
       } 
       return cell; 
      }else if ([challenge.mediaType isEqualToString:@"Video"]) { 
       HGOtherUserVideoCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForVideoCellProfile forIndexPath:indexPath]; 
       cell.challenge = challenge; 
       cell.indexPath = indexPath; 
       cell.baseDelegate = self; 
       if (userLikedChallenges) { 
        if ([userLikedChallenges containsObject:challenge.objectId]) { 
         cell.liked = true; 
        }else{ 
         cell.liked = false; 
        } 
       } 
       if (indexPath.item == 2) { 
        [cell playMuted]; 
       } 
       cell.viewController = self; 
       if (joinedChallenges) { 
        bool joined = false; 
        for (HGActivity * joinedChallengeActivity in joinedChallenges) { 
         if ([joinedChallengeActivity.challenge.objectId isEqualToString:challenge.objectId]) { 
          joined = true; 
          break; 
         } 
        } 
        cell.joined = joined; 
       }else{ 
        cell.joined = false; 
       } 
       return cell; 
      }else{ 
       HGOtherUserMedialessCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifierForMedialessCellProfile forIndexPath:indexPath]; 
       cell.challenge = challenge; 
       cell.indexPath = indexPath; 
       cell.baseDelegate = self; 
       if (userLikedChallenges) { 
        if ([userLikedChallenges containsObject:challenge.objectId]) { 
         cell.liked = true; 
        }else{ 
         cell.liked = false; 
        } 
       } 
       cell.viewController = self; 
       if (joinedChallenges) { 
        bool joined = false; 
        for (HGActivity * joinedChallengeActivity in joinedChallenges) { 
         if ([joinedChallengeActivity.challenge.objectId isEqualToString:challenge.objectId]) { 
          joined = true; 
          break; 
         } 
        } 
        cell.joined = joined; 
       }else{ 
        cell.joined = false; 
       } 
       return cell; 
      } 
     } 
    } 
} 
+0

スクロール後に発生しますか? –

+1

テーブルビューのセルを正しい方法で「再利用」していません。 – rptwsthi

+1

いくつかのコードを表示しますか? –

答えて

0

reloadDataに問題がありました。古いコードは、これまで私はそれを変更し、以下の

[weakSelf.collectionView reloadData]; 

のようだった:

[weakSelf.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]]; 

そして、それは私の問題を解決しました。テキストには不具合がありませんが、写真上の不具合はありません。しかし、それは私がそれを保っているので、涼しく見えた:)

0

あなたは条件に応じて、多くのカスタムセルを示している場合は、あなたが適切テーブルビューのcells.create共通のUITableViewCellクラス(Inを再利用する必要がありたとえばあなたのケース:HGCell)あなたのニーズに応じて多くのペン先を作成することができます(例えば:HGOtherUserTopInformationCell、HGSeperatorCell ...)。以下のコードは、多くのセルを扱う例を示しています。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSString *cellIdentifier = [NSString stringWithFormat:@"Cell%ld",(long)indexPath.row]; 

    NSString *nibName; 

    if(indexPath.item == 0) 
    { 
     nibName = @"HGOtherUserTopInformationCell"; 
    } 
    else 
    { 
     if (indexPath.item % 2 != 0) 
     { 
      nibName = @"HGSeperatorCell"; 
     } 
     else 
     { 
      nibName = @"HGOtherUserPhotoCell"; 
     } 
    } 

    HGCell *cell = (HGCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (cell == nil) { 

     NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil]; 

     for (id currentObject in topLevelObjects){ 
      if ([currentObject isKindOfClass:[UITableViewCell class]]){ 
       cell = (HGCell *) currentObject; 
       break; 
      } 
     } 
    } 

    //access the cell property here 
    cell.backgroundColor = [UIColor lightGrayColor]; 

    return cell; 
}