當然大家大多在使用自定義cell的情況下,會有出現重疊的情況,現在就本人使用的比較方便的解決辦法分享給大家:
一般固定的源代碼:
#import “MyCell.h”
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = [NSString stringWithFormat:@"Cell"];
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];if (cell == nil) { cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
} return cell;}
解決的方案:
#import “MyCell.h”
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = [NSString stringWithFormat:@"Cell"];
MyCell *cell = nil;//這個地方改變了if (cell == nil) {
cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; }
return cell;
}
我使用過程中一般情況下可以解決問題,如沒有達到您的要求,請繼續查找其他資料。