2011-09-05 58 views
0

我在表格视图中使用下面的代码来显示最后一行但是这里的问题是,在使用这个时我无法滚动表格。我为此搜索了很多,但我没有找到解决这个问题的方法。任何人都可以提出一些建议如何解决这个问题。UITable查看不重新加载

- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *MyIdentifier = @"MyIdentifier"; 

// here to draw cell ImageCell is used for customise cell. 

ImageCell *cell = (ImageCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; // changed this 

if (cell == nil) { 
    cell = [[[ImageCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; // changed this 

} 
cell.selectionStyle=UITableViewCellSelectionStyleNone; 
// setting the text 

NSDictionary *messageData = [messageArray objectAtIndex:[indexPath row]]; 
[cell setData:messageData]; 

int lastRowNumber = [tableView numberOfRowsInSection:0]-1; 
NSIndexPath* ip = [NSIndexPath indexPathForRow:lastRowNumber inSection:0]; 
[tableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionNone animated:YES]; 
// Set up the cell 
return cell; 
} 

这是我的代码。

+0

你是什么意思“不能滚动表”吗?另外,为了重新载入表格,你需要在某个时候调用'reloadData',而这个地方不会调用你提供的东西。 – WrightsCS

+0

是的,我无法看到上面的单元格数据。实际上我是在绘制表格 – Vijay

+0

时写入了这个代码,“上面的单元格数据”也没有意义。要么提供更多的isse或更多代码的背景。 – WrightsCS

回答

0

atScrollPosition:UITableViewScrollPositionNone是您的罪魁祸首,使用UITableViewScrollPositionBottomUITableViewScrollPositionTop

+0

我也尝试这个UITableViewScrollPositionTop和UITableViewScrollPositionBottom,但我的问题,因为它是 – Vijay