我正在尝试在Objective C中不使用nib文件来构建应用程序,但是当我在模拟器中运行它时,我的对象都没有显示在屏幕上。我认为错误在我的AppDelegate或ViewController中。非常感谢任何帮助。
AppDelegate.h:
#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow* window;
ViewController* viewController;
}
@property (strong,nonatomic) UIWindow *window;
@property (strong,nonatomic) ViewController* viewController;
@end
AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
@synthesize window;
@synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
viewController=[ViewController new];
[window setRootViewController:viewController];
[window makeKeyAndVisible];
return YES;
}
@end
ViewController.h:
#import <UIKit/UIKit.h>
#import "LoginView.h"
@interface ViewController:UIViewController
-(id) init;
@end
ViewController.m:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(id) init {
self=[super init];
if (self) {
}
return self;
}
-(void) loadView {
LoginView* loginView=[LoginView new];
self.view=loginView;
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
抱歉格式不佳。