按下tableview单元格时更改视图? [英] Change view when tableview cell is pressed?

查看:49
本文介绍了按下tableview单元格时更改视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助。当我的tableView的单元格被选中时,我希望单元格转到它自己的页面,我不希望每个单元格都转到同一页面。我尝试使用:

i need help. When my tableView's cell is selected, i want the cell to go to a page of its own, i don't want every cell to go to the same page. I tried using :

FirstFolderViewController * first = [[FirstFolderViewController alloc]init];
first.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[first presentModalViewController:first animated:YES];
[first release];

我将此添加到didSelectRowAtIndexPath:方法中。但它不会有任何想法?谢谢

i added this to the didSelectRowAtIndexPath: method. but it won't work any idea?? Thanks

推荐答案

首先,albertamg的回答指出了一个重要的概念;应该在 self 上调用 presentModalViewController

First off, albertamg's answer points out an important concept; the presentModalViewController should be called on self.

秒,听起来你需要在你呈现的每个后续视图中都有一些独特的东西,可能是基于创建表格单元格的数据。一种方法是在你的 FirstFolderViewController 上设置一个 @property ,就在它出现之前,然后是它是 viewWillAppear 函数,你可以对该值进行操作。

Second, it sounds like you need to have something unique happen in each subsequent view that you present, presumably based on data that creates your table cell. One way to do this is to set a @property on your FirstFolderViewController, just before you present it, and then when it's viewWillAppear function, is called, you can act on that value.

例如,

FirstFolderViewController * first = [[FirstFolderViewController alloc]init];
first.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

first.folderNumber = indexPath.row; // Added

[self presentModalViewController:first animated:YES];
[first release];

...假设你在中调用它 - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 方法,你在<$里面设置了一个名为 folderNumber 的属性c $ c> FirstFolderViewController 。

...assuming you're calling this inside your - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method, and you've set up a property called folderNumber inside your FirstFolderViewController.

这篇关于按下tableview单元格时更改视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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