我試圖將應用程序委託人連接到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