简体   繁体   English

iPhone SDK-不了解如何从UITableView推送明细表视图

[英]iPhone SDK - don't understand how to push a drill-down table view from UITableView

I am relatively new to iPhone programming and am having difficulty as to where/how to push a selected row's drill-down view from a grouped table view. 我对iPhone编程比较陌生,并且在从组合表视图中将所选行的向下钻取视图推到何处/方式方面遇到困难。 My top-level table view shows OK. 我的顶级表视图显示OK。 I am putting the code for didSelectRowAtIndexPath in RootViewController.m and am telling it to push a new view onto the stack when a row is selected. 我在RootViewController.m放置了didSelectRowAtIndexPath的代码,并告诉它在选择一行时将新视图推送到堆栈上。 However, I cannot get it compiled as it says it does not know of the existence of the new view ("Carbon") and warns that UINavigationController may not respond to pushViewController:animated . 但是,我无法对其进行编译,因为它说它不知道新视图(Carbon)的存在,并警告UINavigationController可能不响应pushViewController:animated I am going round in circles and need some help with the basics of where does this code go - and the correct syntax of the push method. 我正在兜圈子,需要有关此代码去向的基础知识以及push方法的正确语法的一些帮助。 Any help appreciated. 任何帮助表示赞赏。 Thanks, Maxwell 谢谢麦克斯韦

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    Carbon *carbon = [[[carbonDetails alloc] initWithNibName:@"Carbon" bundle:nil] autorelease];

    [self.navigationController PushViewController:carbon animated:YES];
} 

One thing that's probably contributing is this: 可能造成的一件事是:

[self.navigationController PushViewController:carbon animated:YES];

It should be: 它应该是:

[self.navigationController pushViewController:carbon animated:YES];

Notice that it starts with a lowercase p, but you've used an uppercase P. I think that's what's behind the "may not respond ..." stuff. 请注意,它以小写字母p开头,但是您使用的是大写字母P。我认为这就是“可能不响应...”内容的含义。

Also, this part looks wrong too: 另外,这部分看起来也错了:

Carbon *carbon = [[[carbonDetails alloc] initWithNibName:@"Carbon" bundle:nil] autorelease];

I'm assuming your class is called Carbon, so what is carbonDetails? 我假设您的班级称为Carbon,那么carbonDetails是什么? It usually goes like this: 通常是这样的:

Carbon *carbon = [[[Carbon alloc] initWithNibName:@"Carbon" bundle:nil] autorelease];

This says, "give me a pointer to a newly allocated and initialized instance of the Carbon class." 这说:“给我一个指向Carbon类的新分配和初始化实例的指针。”

Also, you'll have to make sure you have imported the Carbon class's header file into this table view controller's implementation file. 另外,还必须确保已将Carbon类的头文件导入到此表视图控制器的实现文件中。 At the top: 在顶部:

#import "Carbon.h"

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

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