简体   繁体   English

将UItableview从普通视图控制器推到详细视图控制器

[英]Pushing a UItableview from a normal view controller to a detail view controller

I have a UItableview custom sized inside a Viewcontroller (for certain reasons, it cannot be inside a navigationcontroller). 我在Viewcontroller内有一个自定义大小的UItableview自定义控件(由于某些原因,它不能在Navigationcontroller内)。 This is set to display a number of cells based on mysql importing into core data. 设置为显示基于mysql导入核心数据的许多单元格。 How do I transition it from one view controller to another when a user clicks on an unknown row? 当用户单击未知行时,如何将其从一个视图控制器转换为另一个视图控制器?

if you have set delegate to you UITableView then 如果您已将delegate设置为UITableView
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath will be called on your delegate when user taps on any cell. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath当用户点击任意单元格时,将在您的委托上调用- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath And then all you need is to find a model in your array or whatever which correspondes to that index path 然后,您所需要做的就是在数组中或与该索引路径对应的任何内容中找到一个模型
(the most common case is [array objectAtIndex:indexPath.row] ) (最常见的情况是[array objectAtIndex:indexPath.row]
And then you can push another view controller to the navigation stack or do a modal one 然后,您可以将另一个视图控制器推入导航堆栈或执行模态控制器

如果您不使用导航控制器,那么我将在tableView:didSelectRowAtIndexPath方法内使用presentViewController:animated:completion:。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM