Alp Alp - 3 months ago 14
iOS Question

iOS application glitch

I am working on debugging an app and there is a glitch. I looked it up on the app and also in the internet but did not find anything.

You can reach the glitch from below

enter image description here

It looks like below for that short time interval.

enter image description here

My code:

- (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;
}
}
}
}

Alp Alp
Answer

There was a problem about reloadData. Old code was like the below

[weakSelf.collectionView reloadData];

I changed it to this:

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

And it solved my problem. There is no more a glitch in the text but a glitch on the pictures. But it looked cool so I am keeping it :)