开发者

ipad: scroll tableView so that searchbar does not get hide below Keyboard

I have a situation here which I am unable to solve because of lack of expertise in iPhone so kindly guide me thru this,

I have a custom table with two search bar in each cell. When I touch the lowest search bar it hides below key board. So camn you tell me some workaround so that it d开发者_开发技巧oesnt hide below keyboard. I tried to use this

[tableView scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated]

but was unable to use it since I was not sure for indexPath.

Please enlighten me on this Thanx in advance :)


You need to know the index path of the cell with the search bar. If the search bar is always in the same cell (it is static) then you just create an NSIndexPath using the below method:

[NSIndexPath indexPathForRow:1 inSection:0];

That is the second row in the first section of the table. 0 means the first, 1 means the second, etc

You just stick that line in the indexPath parameter.

[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];

This will scroll the 2nd row/cell to the bottom of the tableView, animatedly in other words smoothly and it won't just jump.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜