点击UITableViewcell的下一个按钮 [英] hitting a next button for a UITableViewcell
本文介绍了点击UITableViewcell的下一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何实现以下功能:
创建下一个按钮,当它被点击时,将选择下一个UITableview行。
I was wondering how I can realize the following:
Creating a next button and when it's tapped the next UITableview row will be selected.
由于图片胜过千言万语,我添加了截图。
Since a picture is worth a thousand words I've added a screenshot.
http://img529.imageshack.us/img529/4341/picture5uuj.png
如下所示,我添加了一个工具栏,如果按下右键,则必须选择下一行。关于我如何处理这个的任何建议(我假设使用某种迭代器)。
As you can see below I added a toolbar and if I press the right button it has to select the next row. Any suggestions on how I can approach this ( I assume with some sort of iterator).
ps。我希望行也像被触摸一样行动(所以我可以在其后面加一个动作)
推荐答案
这样的事情可以解决这个问题:
Something like this should do the trick:
- (void)selectNextRow
{
NSIndexPath *selectedRow = [self.tableView indexPathForSelectedRow];
NSUInteger row = selectedRow.row;
NSUInteger section = selectedRow.section;
++row;
if(row >= [self.tableView numberOfRowsInSection:selectedRow.section])
{
row = 0;
++section;
if(section >= [self.tableView numberOfSections])
{
row = 0;
section = 0;
}
}
NSIndexPath *rowToSelect = [self tableView:self.tableView willSelectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]];
[self.tableView selectRowAtIndexPath:rowToSelect animated:YES scrollPosition:UITableViewScrollPositionMiddle];
[self tableView:self.tableView didSelectRowAtIndexPath:rowToSelect];
// also, post notifications if desired
}
这篇关于点击UITableViewcell的下一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文