PushViewController 上的 Cell 特定数据
我有一个 NSMutableArray,它进行一些处理并最终拥有多个对象,尽管无法预定义对象的确切数量。
然后,此 NSMutableArray 中的对象显示在 UITableView 上,每个单元格代表 NSMutableArray 中的一个对象。
我想要做的很简单。我想选择一个特定的单元格,然后发送到一个新视图,其中包含特定于数组中该对象的数据。 我已经阅读过有关 PushViewController 的内容,似乎这就是实现此目的的方法,但是在选择单元格时推送的视图中,我希望有一个简单的文本框(用户可以编辑),其中包含特定于该单元格/对象..
由于我无法为pushViewController制作任何nib文件(因为数组中的数据每次都不相同),我能做什么:
- 推送单元格特定的视图控制器。
- 允许用户编辑此文本框。
- 保存文本框数据并以某种方式从 nsmutablearray 连接到单元格/对象。
- 当调用pushviewcontroller时,会从某处加载单元格/对象特定的数据。
I have an NSMutableArray which does some processing and eventually has several objects although the exact number of objects cannot be predefined.
The objects from this NSMutableArray are then displayed on a UITableView, with each cell representing an object in the NSMutableArray..
What i want to do is simple. i want to select a specific cell and then be sent to a new view which has data specific to that object that is in the array.
i have read about pushViewController and it seems like it would be the way to this, however in the view that gets pushed when a cell is selected, i want there to be a simple textbox (that the user can edit) that has data specific to that cell/object..
As i cant make any nib files for the pushViewController (because the data in the array is not the same every time), what can i do to:
- Push cell specific viewcontroller.
- allow user to edit this textbox.
- save textbox data and somehow connect to cell/object from nsmutablearray.
- when pushviewcontroller is called, cell/object specific data is loaded from somewhere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如,您可以在子视图控制器上创建一个属性并从父视图中检索该项目。我假设您使用 UITableView 之类的东西作为父级,因此您可以使用
indexPathForSelectedRow
消息获取所选项目的索引。You could, for example, create a property on your child view controller and retrieve the item from the parent view. I assume that you use something like a UITableView as the parent, so you can get the index for the selected item with the
indexPathForSelectedRow
message.