在我的應用程序中,我最初只會在UITableView
上顯示一行。我想在用戶用數據加載前一行時增加行(這裏是一個uiimage)。就像現在我返回值1,在numberOfRowsInSection:
方法中一樣,因爲我不知道如何以所需的方式實現它。請幫忙。向UITableViewCell添加新行
我cellForRowAtIndexPath:
方法是
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CustomCellIdentifier ] autorelease];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id currentObject in nib){
if ([currentObject isKindOfClass:[CustomCell class]]){
cell = (CustomCell *)currentObject;
cell.viewController = self;
break;
}
}
}
if (j<15){
cell.imageView.image = nil;
if (count!=0)
{
@try{
NSInteger row = [indexPath row];
cell.imageView.image = [array objectAtIndex:row];
}
@catch (NSException* ex) {
NSLog(@"doSomethingFancy failed: %@",ex);
}
}
}
cell.showsReorderControl = YES;
return cell;
[array release];
}
,如果條件和次數也不過只是爲了檢查可變數組,「陣」的正確運行。
感謝您的回覆... – Nithin 2009-12-09 05:28:43