Iphone 将TableViewController添加到现有项目
我有一个现有的TableViewController,如下所示Iphone 将TableViewController添加到现有项目,iphone,xcode,uiview,sdk,uiapplicationdelegate,Iphone,Xcode,Uiview,Sdk,Uiapplicationdelegate,我有一个现有的TableViewController,如下所示 // TableViewController.h @interface TableViewController : UITableViewController { NSArray *dataArray; } @property (nonatomic, retain) NSArray *dataArray; 和navAppDelegate-具体而言: // navAppDelegate.h #import <UIKit/U
// TableViewController.h
@interface TableViewController : UITableViewController { NSArray *dataArray; }
@property (nonatomic, retain) NSArray *dataArray;
和navAppDelegate-具体而言:
// navAppDelegate.h
#import <UIKit/UIKit.h>
@interface navwAppDelegate : NSObject
<UIApplicationDelegate, UINavigationControllerDelegate> {
UIWindow *window;
IBOutlet UINavigationController *navigationController;}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UINavigationController *navigationController;
// navAppDelegate.m
#import "navAppDelegate.h"
@implementation navigationtableviewAppDelegate
@synthesize window, navigationController;
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[window makeKeyAndVisible];
[window addSubview:[navigationController view]];
}
试试看。这就是你想要的吗
如果是这样,我所做的就是创建一个表视图控制器的新实例,并将其推送。在您的原始代码中,您试图推送无法完成的应用程序委托;应用程序委托不是视图控制器。不过,您的UITableViewController子类TableViewController是,因此您可以将其用于pushViewController:方法,并且表格视图将显示在屏幕上。谢谢。杰出的但它并不是这样工作的——经过两天的艰苦工作,我成功地运行了它。对于那些感兴趣的人,以下是我所做的:
- (void)LetsGoButtonTouched {
TableViewController *tvc = [[[TableViewController alloc] init] autorelease];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:tvc]autorelease];
[self presentModalViewController:navigationController animated:YES];
- (void)LetsGoButtonTouched {
TableViewController *tableViewController = [[TableViewController alloc] init];
[[self navigationController] pushViewController:tableViewController animated: YES];
}
- (void)LetsGoButtonTouched {
TableViewController *tvc = [[[TableViewController alloc] init] autorelease];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:tvc]autorelease];
[self presentModalViewController:navigationController animated:YES];