如何跳转到detailview的下一行 [英] How to jump to the next row in detailview

查看:133
本文介绍了如何跳转到detailview的下一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TableView加载一个detailview在didSelectRow。我对数据没有问题。
我使用coreData和填充TableView我使用一个NSFetchedResultsController。

i have a TableView which loads a detailview in didSelectRow. I have no problems with the data's. I am using coreData and to populate the TableView i am using a NSFetchedResultsController.

现在,我想做一个下一个和上一个函数在detailView 跳转到下一个或上一个表(行)元素。下一页上一页类似于邮件应用程序。

我知道我必须使用带有IBAction的按钮。

Now, i want to make a next and previous function in the detailView to jump to the next or previous Table(row) Element. Next Previous like in the Mail-App.
I know that i have to use a button with IBAction.

使此功能?

感谢,

brush51

thanks,
brush51

Edit 1:
我这样做:

Edit 1: I have it done so:

- (IBAction) previousCard:(id) sender {  
    NSLog(@"previousBtn");

DashboardViewController *parent = (DashboardViewController *)self.parentViewController;

NSIndexPath *actualIndexPath = selectedRow2;
NSIndexPath * newIndexPath = [NSIndexPath  indexPathForRow:actualIndexPath.row-1 inSection:actualIndexPath.section];
NSLog(@"newIndexPath: %@", newIndexPath);
[parent.tableViews selectRowAtIndexPath:newIndexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle]; //HERE I GET SIGABRT

}

但我得到一个错误:

-[UIViewController tableViews]: unrecognized selector sent to instance 0xd758ae0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableViews]: unrecognized selector sent to instance 0xd758ae0'  

解决这个问题?

推荐答案

使用UITableView,您可以通过以下方式获取所选行:

With your UITableView, you can get the selected row by:

- (NSIndexPath *)indexPathForSelectedRow

通过递增indexPath.row设置选择:

And set the selection by incrementing the indexPath.row:

- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition

那么您的操作可以是:

-(IBAction)nextCell:(id)sender {
  NSIndexPath * actualIndexPath = myTableView.indexPathForSelectedRow;
  NSIndexPath * newIndexPath = [NSIndexPath  indexPathForRow:actualIndexPath.row+1 inSection:actualIndexPath.section];
  [myTableView selectRowAtIndexPath:newIndexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
}

这篇关于如何跳转到detailview的下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆