how to next detailView like in Mail-App

空扰寡人 提交于 2020-01-02 23:01:28

问题


i want to jump in my detailview through the rows of my tableview.

passing the data from the tableview to detailview works fine. passing the indexpath.row working fine, too.

in the detailview i can change the indexpath of the row and by returning to the tableview the changed row is selected right.

And my problem is that i cant view the data of new selected row in the detailview.

i hope you understand what i am trying to do :)

for example like in the mail app: i want to push the "next" button and get the associated data .

Next function:

- (IBAction)nextRow:(id) sender {
NSLog(@"nextBtn");


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

NSIndexPath *actualIndexPath = detailselectedRow;
NSIndexPath * newIndexPath = [NSIndexPath indexPathForRow:actualIndexPath.row+1 inSection:actualIndexPath.section];


if([parent.view.subviews objectAtIndex:0]) {
    UIView * subview = (UIView *) [parent.view.subviews objectAtIndex:0];
    UITableView *tView = (UITableView *) subview;


    [tView selectRowAtIndexPath:newIndexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
    [tView.delegate tableView:tView didSelectRowAtIndexPath:newIndexPath];
}
}

Here is my sample application for better understanding what i have done jet: http://www.file-upload.net/download-3896312/TableRotate.zip.html


回答1:


Would you like to show new detail information when click left or right button in detail Page , right?

In the Parent View Class (TableView Layout), you should create NSMutableArray that contain some specific object (ex. "MailDetailObject" that containg data1 , data2 ,data 3 ,... as you wish)

and you could keep each MailDetailObject contain each detail information and put them together to NSMutableArray in Parent View Class

and now , when you didselectRowAtIndexPath in tableView , send this NSMutableArray and your current index on tableView to DetailView (Don't forget to create this property in DetailView for refer object that send from parentView)

In the detailView , (IBAction)nextRow Method , if you click next you can refer to the next index and lookup in NSMutableArray that have sent from your parentView and get the next index information to display

hope it helps you



来源:https://stackoverflow.com/questions/8241463/how-to-next-detailview-like-in-mail-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!