【问题标题】:how to next detailView like in Mail-App如何在 Mail-App 中进行下一个 detailView
【发布时间】:2012-01-04 16:51:09
【问题描述】:

我想通过我的 tableview 的行跳转到我的 detailview。

将数据从 tableview 传递到 detailview 工作正常。 传递 indexpath.row 也可以正常工作。

在详细视图中,我可以更改行的索引路径,并通过返回到 tableview 来正确选择更改的行。

我的问题是我无法在详细视图中查看新选定行的数据。

我希望你明白我想要做什么:)

例如在邮件应用程序中:我想按下“下一步”按钮并获取相关数据。

下一个函数:

- (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];
}
}

这是我的示例应用程序,以便更好地了解我所做的 jet:http://www.file-upload.net/download-3896312/TableRotate.zip.html

【问题讨论】:

    标签: ios uitableview row next detailview


    【解决方案1】:

    在详情页中单击左键或右键时是否要显示新的详情信息,对吗?

    在父视图类(TableView 布局)中,您应该创建包含一些特定对象的 NSMutableArray(例如“MailDetailObject”,其中包含 data1 , data2 ,data 3 ,...如您所愿)

    你可以让每个 MailDetailObject 包含每个细节信息,并将它们放在父视图类中的 NSMutableArray 中

    现在,当您在 tableView 中 didselectRowAtIndexPath 时,将此 NSMutableArray 和您在 tableView 上的当前索引发送到 DetailView (不要忘记在 DetailView 中为从 parentView 发送的引用对象创建此属性)

    在detailView (IBAction)nextRow Method 中,如果点击next,可以参考NSMutableArray中从parentView发送过来的下一个索引和查找,得到下一个要显示的索引信息

    希望对你有帮助

    【讨论】:

    • 我想按照你说的做。但是如何将对象数据保存在可变数组中? [mutableArray setValue:data_X forKey:@"MailDetailObject"] 不会将任何内容保存到 mutableArray。
    • 使用 [mutableArray addObject:yourObject];如果你想知道 mutableArray 的长度是多少 [mutableArray count];
    • 我已经在我的应用程序中使用 [mutableArray addObject:]。抱歉,我对“MailDetailObject”的原因感到困惑,考虑保存特定的键值。我已经按照你说的做了,我的问题已经解决了......第一次:) 非常感谢你,享受赏金的乐趣
    • 你能告诉我如何解决它,当我使用 coreData 时?还是我应该开始一个新问题?
    • 很高兴为您提供帮助。要简单,尽量使用简单的方法或工具,不要让你的代码复杂
    猜你喜欢
    • 2012-04-09
    • 2019-05-05
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-25
    • 1970-01-01
    相关资源
    最近更新 更多