开发者

adding subviews to UITableViewCell issue

开发者 https://www.devze.com 2023-03-09 08:25 出处:网络
I have a UITableView , in which if I tap on one of the rows it adds a subview at the bottom. The issue is that when I tap the last row in the table, it hides the subviews and having me to scroll to th

I have a UITableView , in which if I tap on one of the rows it adds a subview at the bottom. The issue is that when I tap the last row in the table, it hides the subviews and having me to scroll to the bottom to see it. It's a small bug, but what is the best way to remedy this issue.

One way I can think 开发者_Go百科of is to scroll down to the bottom of the row if the last row is selected. This doesn't seem to be a very good solution though.

Here's a video illustrating my issue


You may want to try something like this in the didSelectRow method:

if (indexPath.row == [dataArray count]) {
  [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row
                                                       inSection:0]
                   atScrollPosition:UITableViewScrollPositionBottom 
                           animated:YES];   
}

I've also used the following for making the last row visible (though from your video I do not think this will work for your situation)

[guessesTableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
0

精彩评论

暂无评论...
验证码 换一张
取 消