我有一个由plist填充的tableview,当单击一个单元格时,detailViewController中的textview将由plist中关联的值的字符串填充。
所有这些工作都很完美,但是现在我想在detailViewController
中添加previous和next按钮,它将遍历tableview。
下面是我的prepareForSegue
上的TableViewController
:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"promisePush"])
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
NSInteger section = [indexPath section];
NSString *key = [uniqueArray objectAtIndex:section];
NSArray *nameSection = [sections objectForKey:key];
NSDictionary *dictionary = [nameSection objectAtIndex:indexPath.row];
DetailViewController *dvController = [segue destinationViewController];
//dvController.array = titles;
dvController.selectedRow = indexPath.row;
dvController.titleCat = [dictionary valueForKey:@"Title"];
dvController.kjvText = [dictionary valueForKey:@"kjvText"];
dvController.nkjvText = [dictionary valueForKey:@"nkjvText"];
dvController.nivText = [dictionary valueForKey:@"nivText"];
dvController.verse = [dictionary valueForKey:@"verse"];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Promises" style:UIBarButtonItemStyleBordered target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
}
}
现在kjvText被传递给detailViewController中名为txtdText的textView
[txtdText setText:nkjvText];
我能够通过dvController.selectedRow = indexPath.row;
并可以迭代int到下一个数字通过
- (IBAction)nextPromise:(UIButton *)sender {
selectedRow = selectedRow + 1;
}
但是我不知道如何将这个数字传递给tableView中的下一个indexPath.row,它将更新detailViewController中的textView。
我有一种感觉,我需要设置TableViewController作为我的DetailViewController的委托,但我不太确定那会是什么样子。任何方向都非常赞赏!
1条答案
按热度按时间x0fgdtte1#
如果我理解正确的话,你不能简单地在你的UITableView上调用下面的方法吗?
这将选择由索引路径标识的接收器中的行,可选地将该行滚动到接收器中的某个位置。请参阅UITableView上的文档。