我有一個TableView,它在didSelectRow中加載detailview。我對這些數據沒有任何問題。 我正在使用coreData和填充TableView我使用NSFetchedResultsController。如何跳轉到詳細視圖中的下一行
現在,我想使detailView 中的下一個和上一個函數跳轉到下一個或上一個表(行)元素。下一個上一個喜歡在郵件應用程序。
我知道我必須使用帶有IBAction的按鈕。
但是我怎樣才能使這個功能?
感謝,
brush51
編輯1: 我有它這樣做:
- (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'
如何解決這個?
謝謝。我怎樣才能在detailview中設置我的tableView?還是我在這裏錯過了一部分? – brush51
您可以將詳細視圖控制器中的引用添加到父控制器,當您推送詳細控制器時,在didSelectRowAtIndexPath上分配父控制器 –
以及如何操作?你能解釋一下嗎? Iam對我在ios上的低級體驗感到抱歉。 – brush51