В моем табличном представлении у меня было более 200 строк, и я управляю ими, сохраняя loadmoreresults в последней ячейке, чтобы отобразить только 40 строк на страницу. Когда пользователь нажимает на загрузку, результаты отображаются еще на 40 ячеек. Высота ячейки грузоподъемности отличается от других. Проблема в том, что когда больше нет результатов, высота для другой ячейки зависит от высоты ячейки loadmoreresults. Я не хочу влиять на высоту последней строки на другие строки.
Код, который я написал как:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
ZohoAppDelegate* appDelegate = (ZohoAppDelegate*) [ [UIApplication sharedApplication] delegate];
int maxResults = [appDelegate.invoiceMaxValues intValue];
int noOfResults = [invoiceArray count] ;
if (noOfResults != 0 )
{
if (maxResults > noOfResults)
{
noOfResults++;
rowCount = noOfResults;
}
}
return noOfResults;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == (rowCount -1))
{
return 50;
}
return 80;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MasterViewIdentifier"] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryNone;
UIView* elementView = [[UIView alloc] initWithFrame:CGRectMake(5,5,312,480)];
elementView.tag = 0;
[cell.contentView addSubview:elementView];
[elementView release];
}
UIView* elementView = [cell.contentView viewWithTag:0];
for(UIView* subView in elementView.subviews)
{
[subView removeFromSuperview];
}
UIImageView* imaeView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 78)];
if(indexPath.row == (rowCount-1))
{
elementView.backgroundColor = [UIColor colorWithRed:0.92578125 green:0.92578125 blue:0.92578125 alpha:1];
}
else
{
imaeView.image=[UIImage imageNamed:@"estimatecellbg.png" ];
}
[elementView addSubview:imaeView];
[imaeView release];
return cell;
}
Любая помощь будет высоко ценится.
Спасибо,
Мониш.