我創建了一個自定義的UITableViewCell,但是當我出列的單元格,有時它拋出一個NSInvalidArgumentException:爲什麼自定義UITableViewCell會導致NSInvalidArgumentException?
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell lblMonth]: unrecognized selector sent to instance 0x6aa7df0
現在,我的自定義的UITableViewCell確實有一個屬性lblMonth,所以我很困惑,爲什麼它是引發此錯誤。下面是代碼我使用出列的單元格:
(UITableViewCell的*)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *cell;
cell = [(CustomCell*)[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
if (cell == nil){
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"New_Phone" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[CustomCell class]])
{
cell = (CustomCell *)currentObject;
break;
}
}
}
CGFloat emival= emi;
CGFloat curinterest = balarray[indexPath.row] * interset;
if(indexPath.row == tenure){
emival = balarray[indexPath.row-1] + curinterest;
}
CGFloat curamnt = emival - curinterest;
balarray[indexPath.row]=balarray[indexPath.row]-curamnt;
[[cell lblMonth]setText:[NSString stringWithFormat:@"%d", indexPath.row+1]];
[[cell lblEMI]setText:[NSString stringWithFormat:@"%.f", emival]];
[[cell lblInterest]setText:[NSString stringWithFormat:@"%.f", curinterest]];
[[cell lblPrinicipal]setText:[NSString stringWithFormat:@"%.f", curamnt]];
[[cell lblBalance]setText:[NSString stringWithFormat:@"%.f", balarray[indexPath.row]]];
return cell;}
請幫我在這...由於提前
我面臨與其他問題too..when曾經我滾動tableview中值越來越changed..please幫我在這個.... – vsandeepraju 2012-02-29 07:33:01
按照代碼標籤值將根據更新在indexPath.row上。這不是預期的行爲。哪些值不應該改變? – Ravin 2012-02-29 08:32:40