我想在我的详细视图中跳转到我的表格视图的行。
将数据从表视图传递到详细视图效果很好。
传递indexpath.row也工作正常。
在详细视图中,我可以更改行的索引路径,并通过返回表视图来正确选择更改的行。
我的问题是我无法在详细视图中查看新选定行的数据。
我希望你明白我想要做什么:)
例如在邮件应用程序中:我想按“下一步”按钮并获取相关数据。
下一个功能:
- (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];
}
}
这是我的示例应用程序,以便更好地理解我所做的喷射: http://www.file-upload.net/download-3896312/TableRotate.zip.html
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)
您想在详细页面点击左键或右键时显示新的详细信息吗?
在父视图类(TableView 布局)中,您应该创建包含某些特定对象的 NSMutableArray (例如,包含 data1 、 data2 、data 3 等的“MailDetailObject”,如您所愿),
并且您可以让每个 MailDetailObject 包含每个详细信息信息并将它们放在父视图类中的 NSMutableArray 中
,现在,当您在 tableView 中
didselectRowAtIndexPath
时,将此 NSMutableArray 和 tableView 上的当前索引发送到DetailView (不要忘记在 DetailView 中创建此属性以引用从parentView发送的对象)在DetailView中,
(IBAction)nextRow方法
,如果单击“下一步”,您可以引用下一个索引并查找在 NSMutableArray 中从你的parentView发送并获取下一个索引信息来显示希望它可以帮助你
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 displayhope it helps you