이 내 문제입니다. 스크롤 할 때 UITableViewController가 지연됩니다. 그것에는 대략 60의 주문 세포가있다. 그러나 시뮬레이터에서는 어떤 지체없이 작동합니다. ,스크롤 할 때 UITableView의 뒤가
#import "CustomCell.h"
@implementation CustomCell
@synthesize nameLabel,costLabel,giftPicture;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
nameLabel = [[UILabel alloc]init];
nameLabel.textAlignment = UITextAlignmentLeft;
nameLabel.textColor = [UIColor colorWithRed:25/256.0 green:98/256.0 blue:52/256.0 alpha:1.0];
costLabel = [[UILabel alloc]init];
costLabel.textAlignment = UITextAlignmentLeft;
giftPicture = [[UIImageView alloc]init];
[self.contentView addSubview:nameLabel];
[self.contentView addSubview:costLabel];
[self.contentView addSubview:giftPicture];
costLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background4"]];
nameLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background4"]];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGRect contentRect = self.contentView.bounds;
CGFloat boundsX = contentRect.origin.x;
CGRect frame;
frame= CGRectMake(boundsX+10,10, 50, 50);
giftPicture.frame = frame;
frame= CGRectMake(boundsX+70 ,10, 350, 25);
nameLabel.frame = frame;
frame= CGRectMake(boundsX+70 ,40, 350, 18);
costLabel.frame = frame;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
List.m
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [array1 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithFrame:CGRectZero];
}
// Configure the cell...
NSString *cellValue = [array1 objectAtIndex:indexPath.row];
//cell.textLabel.text = cellValue; // загаловок клетки
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; // сделал чтобы клетка была со стрелочкой
cell.nameLabel.text = cellValue;
NSDictionary *mainDictionary = [[NSDictionary alloc]init];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
if([currentLanguage isEqualToString:@"en"])
{
mainDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"animals" ofType:@"txt"]];
}
NSEnumerator *enumerator = [mainDictionary objectEnumerator];
id returnValue;
while ((returnValue = [enumerator nextObject]))
{
if([cell.nameLabel.text isEqualToString:[returnValue valueForKey:@"name"]])
{
cell.animalPicture.image = [UIImage imageNamed:[returnValue valueForKey:@"icon"]];
cell.costLabel.text = [NSString stringWithFormat:@"$%@ - $%@",[returnValue valueForKey:@"minAge"],[returnValue valueForKey:@"maxAge"]];
}
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 75;
}
@end
난 그냥 때문에 호기심의 사용자 정의 셀이 비어 있도록 (라벨과 이미지를 제거)을 시도했으나 CustomCell.m : 다음은 내 코드입니다 그러나 그것은 아무것도 바뀌지 않았습니다. 제발 말해 줄래, 내가이 지연을 수정하려면 무엇을 확인해야합니까? 감사합니다.
확실치 않지만,'CustomCell' 클래스와 관련이있을 수 있습니다. 각 셀에 여러보기가 포함되어 있으며 스크롤시 지연이 발생할 수 있습니다. – sooper