为每个UITableViewCell的另一个视图创建一个链接 [英] Make a link for each UITableViewCell with another view

查看:90
本文介绍了为每个UITableViewCell的另一个视图创建一个链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS编程的新手,我想做一件简单的事情。我看到了几个有关我的问题的主题,但是我不明白为什么我的代码不起作用...

I'm new in iOS programming, and I want to do a simple thing. I saw several topics about my problem, but I don't understand why my code doesn't work...


  • 我创建了一个UIViewController子类名为details2ViewController,带有.xib

  • 在名为 ViewController.xib 的主视图中,我有一个tableView

  • ViewController.m 中,我在顶部添加: #import details2ViewController.h

  • ViewController.m 中,我修改了 didSelectRowAtIndexPath 方法,如下所示:

  • I created a UIViewController subclass called details2ViewController, with a .xib
  • In my main view called ViewController.xib, I have a tableView
  • In ViewController.m, I added on the top : #import "details2ViewController.h"
  • In ViewController.m, I modified the didSelectRowAtIndexPath method like this :

details *det = [[details alloc] init];
[self.navigationController pushViewController:det animated:YES];


没有警告,但在以下情况下无效我单击一个单元格。。。精确地说,我没有mainStoryBoard。

There is no warning, but no effect when I click on a cell... I precise that I'm working without mainStoryBoard.

注意:此处是我以前关于此问题的发布。

note : Here's my previously post about this problem.

(对不起,如果我的英语不好,我是法语...谢谢您的帮助!)

(Sorry if my english is awkward, I'm french... Thanks for your help !)

推荐答案

首先,检查您是否已将TableView的委托正确连接到ViewController的文件所有者。 TableView的 -didSelectRowAtIndexPath 方法是一个委托方法。

First of all check that you have properly wired your TableView's delegate to your ViewController's File Owner or not. TableView's -didSelectRowAtIndexPath method is a delegate method.

第二,我不明白为什么要使用<$ c $当您已经导入了 details2ViewController.h 时,将c> details 作为类名。因此,看起来您应该使用 details2ViewController 而不是 details ,并且您的代码应如下所示:

Secondly, I am not getting why are using details as a Class name when you already have imported details2ViewController.h. So, It looks like you should use details2ViewController instead details and your code should look like this :

 details2ViewController *det = [[details2ViewController alloc] initWithNibName:@"details2ViewController" bundle:nil];
[self.navigationController pushViewController:det animated:YES];






请确保您的实际上,ViewController 已嵌入在 UINavigationController 中。如果不是,那么您的 self.navigationController将变为 nil


Make sure that your ViewController is indeed embedded in a UINavigationController. If not then your self.navigationController will be nil.

或者您可以浏览 UINavigationController简介

这篇关于为每个UITableViewCell的另一个视图创建一个链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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