开发者

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. My top-level table view shows 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. However, I cannot get i开发者_如何学编程t 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. 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. 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.

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? 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."

Also, you'll have to make sure you have imported the Carbon class's header file into this table view controller's implementation file. At the top:

#import "Carbon.h"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜