我想向我的 customCell.m 添加一个方法,它允许我在一行中添加有关单元格的信息,所以我添加了:
-(void) addInfo:(NSString*) pTitre:(NSString*) pDescritption:(NSString*) pDate: (NSString*)pImage
{
[[self titre] setText:pTitre];
[[self description] setText:pDescritption];
[[self date] setText:pDate];
[[self couverture] setImage:[UIImage imageNamed:pImage]];
}
但是当我在 mytableview.m 中调用该方法时,如下所示:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3 ;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"firstviewcustomcellCell";
firstviewcustomcellCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
NSArray *topLevelObject=[[NSBundle mainBundle] loadNibNamed:@"firestViewCell" owner:nil options:nil];
for(id currentObject in topLevelObject)
{
if([currentObject isKindOfClass:[firstviewcustomcellCell class]])
{
cell=(firstviewcustomcellCell*) currentObject;
break;
}
}
}
[cell addInfo:
@"journal 1":
@"description 1":
@"01/02/2012":
@"second.png"];
[cell addInfo:
@"journal 2":
@"description 2":
@"01/02/2012":
@"second.png"];
return cell;
}
这就是它所显示的:
http://img213.imageshack.us/img213/2346/capturdcran20120416142.png
感谢您的时间