static NSString *CellIdentifier = @"TweetListUserName";
CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]autorelease] ;
}
一個單元格,使用下面的代碼來設置一個節頭的小區標識:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView* customView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, -4.0, 320.0, 67.0)]autorelease];
[customView setOpaque:YES];
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(-2.0, -4.0, 328.0, 67.0)];
[image setImage:[UIImage imageNamed:@"header-msg.png"]];
[image setOpaque:YES];
[customView addSubview:image];
UILabel *label1 =[[UILabel alloc] initWithFrame:CGRectMake(10, 5, 100, 12)];
label1.text [email protected]"TWEETS MATCHING:";
label1.textAlignment=UITextAlignmentLeft;
[label1 setTextColor:[UIColor grayColor]];
[label1 setFont:[UIFont fontWithName:@"Helvetica" size:9]];;
[label1 setBackgroundColor:[UIColor clearColor]];
[customView addSubview:label1];
[label1 release];
UILabel *label2 =[[UILabel alloc] initWithFrame:CGRectMake(10, 6, 315, 50)];
label2.text =usernametag;
label2.textAlignment=UITextAlignmentLeft;
[label2 setTextColor:[UIColor blackColor]];
[label2 setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
[label2 setBackgroundColor:[UIColor clearColor]];
[customView addSubview:label2];
[label2 release];
return customView;
}
然而,當我快速滾動表頭幾乎在所有情況下閃爍。我怎樣才能防止這種閃爍?
實際上沒有在代碼中提到,但我釋放自定義視圖 – crystal 2009-12-24 06:13:25
這不是該單元格閃爍標題的原因。我知道這是一個古老的問題......但現在發生在我身上。 – Jann 2011-08-10 15:43:27
你是否在重複調用的任何地方調用[tableView reloadData]? – RickiG 2011-08-11 09:46:24