私はUITableView
すべてのセルの画像を持っていますが、すべての画像はすでにセルにあり(私は自分で画像を設定していません)、プロジェクトに含まれている画像からすべてロードされています。これらは、サーバーなどからロードされている画像ではありません。ただし、テーブルビューのスクロールはまだ多少ぎくしゃくしています。それをスピードアップするためにできることはありますか?ここにセルを生成する関数があります:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Post init, update with the fair info so it can attend/de-attend on its own
CompaniesCustomCell *cell = [CompaniesCustomCell dequeOrCreateInTable:tableView];
SectionInfo *sectionInfo = [sectionInfoArray objectAtIndex:indexPath.section];
cell.fairDictionary = [sectionInfo.arrMDetails objectAtIndex:indexPath.row];
[cell updateEventIcon:(NSString*)[[sectionInfo.arrMDetails objectAtIndex:indexPath.row] valueForKey:@"TYPE"]];
cell.lblFairName.text = [[sectionInfo.arrMDetails objectAtIndex:indexPath.row] valueForKey:@"TITLE"];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
// Set event start time, end time, and date
NSString *newDate = [MyUtil convertToLocalTime:@"MMMM dd, yyyy" :[[sectionInfo.arrMDetails objectAtIndex:indexPath.row] valueForKey:@"START_TIME"]];
NSString *startString = [MyUtil convertToLocalTime:@"hh:mm a" :[[sectionInfo.arrMDetails objectAtIndex:indexPath.row] valueForKey:@"START_TIME"]];
NSString *endString = [MyUtil convertToLocalTime:@"hh:mm a" :[[sectionInfo.arrMDetails objectAtIndex:indexPath.row] valueForKey:@"END_TIME"]];
cell.lblFairDate.text = newDate;
cell.lblFairStartTime.text = startString;
cell.lblFairEndTime.text = endString;
return cell;
}
それを遅くする可能性のある私が間違っていることはありますか?
編集
convertToLocalTime
これが根本的な原因である可能性があるため、ここに関数のコードを含めています。しかし...私はそれを最適化する方法を本当に混乱しています。サーバーからタイムスタンプ値(UTC)を取得し、それをユーザーのローカルタイムゾーンに変換しています。このプロセスは本当に遅いですか?
// Converts given time string into the users current timezone
// based on the location of their phone
+(NSString *)convertToLocalTime:(NSString*)format :(NSString*)stringDate {
// Get the date in the servers time zone
NSDate *date = [MyUtil convertToServerDate:stringDate];
// Convert the date to the local timezone
NSDateFormatter *localFormat = [[NSDateFormatter alloc] init];
[localFormat setDateFormat:format];
NSString *localDate = [localFormat stringFromDate:date];
[localFormat release];
return localDate;
}
// Provides a NSDate object with the servers timezone set
+(NSDate *)convertToServerDate:(NSString*)stringDate {
// First get the NSDate object in the servers timezone
NSTimeZone *tz = [NSTimeZone timeZoneWithName:ServerTimezone];
NSDateFormatter *inFormat = [[NSDateFormatter alloc] init];
[inFormat setDateFormat:@"yyyyMMddHHmmss"];
[inFormat setTimeZone:tz];
NSDate *date = [inFormat dateFromString:stringDate];
[inFormat release];
return date;
}