/*直接上代码 代码执行后,cell...indexPath <p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo;">ableView numberOfRowsInSection 等等delegate方法都重新调用了,但是cell就是不刷新 。。。<span style="background-color: rgb(255, 0, 0);"><span style="color:#ffffff;">以下是有问题的代码</span></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 11px; font-family: Menlo;">**/</p>
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"************************");
static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
UITableViewCell *cell;// = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
if ([self.select isEqualToString:@"pending"]) {
UINib *nib = [UINib nibWithNibName:@"TRPendingPayTableViewCell" bundle:nil];
[self.formTableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier];
TRPendingPayTableViewCell *pendingCell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
cell = pendingCell;
}else if ([self.select isEqualToString:@"ing"]){
UINib *nib = [UINib nibWithNibName:@"TRIngTableViewCell" bundle:nil];
[self.formTableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier];
TRIngTableViewCell *ingCell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
cell = ingCell;
}
return cell;
}
对比字符串对比,加载不同的xib,
下面贴出cell可以正常刷新的代码:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"************************");
//static NSString *CustomCellIdentifier = @"CustomCellIdentifier"; //不能放在这
UITableViewCell *cell;// = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
if ([self.select isEqualToString:@"pending"]) {
static NSString *CustomCellIdentifier = @"CustomCellIdentifier"; //放到这里
UINib *nib = [UINib nibWithNibName:@"TRPendingPayTableViewCell" bundle:nil];
[self.formTableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier];
TRPendingPayTableViewCell *pendingCell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
cell = pendingCell;
}else if ([self.select isEqualToString:@"ing"]){
static NSString *CustomCellIdentifier = @"Cell"; //这里也加一个,但是字符串不能一样
UINib *nib = [UINib nibWithNibName:@"TRIngTableViewCell" bundle:nil];
[self.formTableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier];
TRIngTableViewCell *ingCell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier forIndexPath:indexPath];
cell = ingCell;
}
return cell;
}