我试图将应用程序委托人连接到Xcode4中的视图控制器,但由于某种原因我无法建立连接,因为App Delegate无法在可视对象编辑器中看到它。应用程序委托人看不到视图控制器
在视觉对象编辑器中添加了视图控制器,并将类ID更改为HelloWorldViewController,并在App Delegate.h和.m文件中添加了代码。
我在做什么错?
下面是代码:
testWindowBasedAppDelegate.h
// -- Add a forward reference to the HelloWorldViewController class --
@class HelloWorldViewController;
#import <UIKit/UIKit.h>
@interface testWindowBasedAppAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
//-- create an instance of the view controller --
HelloWorldViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
// -- expose the view controller as a property --
@property (nonatomic, retain) HelloWorldViewController *viewController;
@end
testWindowBasedAppDelegate.m
#import "testWindowBasedAppAppDelegate.h"
#import "HelloWorldViewController.h"
@implementation testWindowBasedAppAppDelegate
@synthesize window;
//-- synthesize the property--
@synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
//-- add the new view to the current window --
[window addSubview:viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
- (void)dealloc
{
[viewController release];
[window release];
[super dealloc];
}
@end
到底是什么问题吗?你想做什么?尝试附上代码,我可以看看它 – Sum