移除Main.storyboard关联
修改AppDelegate
- (BOOL )application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog (@"didFinishLaunchingWithOptions" );
self .window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds ];
self .window .backgroundColor = [UIColor whiteColor];
ViewController *view = [[ViewController alloc]init];
[self .window makeKeyAndVisible];
[self .window setRootViewController:view];
return YES ;
}
然后就可以在ViewController里实现界面
- (void )viewDidLoad {
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc]init];
int ScreenWidth = [[UIScreen mainScreen] bounds].size .width ;
int ScreenHeight = [[UIScreen mainScreen] bounds].size .height ;
[scrollView setContentSize:CGSizeMake(ScreenWidth, ScreenHeight)];
[self .view addSubview:scrollView];
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(100 , 100 , 100 , 100 )];
[img setImage:[UIImage imageNamed:@"welcome" ]];
[img setContentMode:UIViewContentModeScaleAspectFill];
[img setUserInteractionEnabled:YES ];
[self .view addSubview:img];
}