我想添加到我的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/capturedcran20120416142.png
感谢您的时间
是不是要'addInfo'覆盖第一个呼叫第二个电话? – trojanfoe 2012-04-16 12:32:01
不应该是一个不同的细胞? – Hosni 2012-04-16 12:54:24
@Nit已经指出,您需要某种*逻辑*来确定填充单元的方式 - 您对所有单元总是做同样的事情,因此您看到了结果。 – trojanfoe 2012-04-16 12:57:08