// ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
// ViewController.m
#import "ViewController.h"
@implementation ViewController
- (
void
)viewDidAppear:(
BOOL
)animated {
[super viewDidAppear:animated];
UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 50)];
myView.backgroundColor=[UIColor redColor];
[self.view addSubview:myView];
}
- (
BOOL
)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return
YES;
}
@end
// AppDelegate.h
#import <UIKit/UIKit.h>
@
class
ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
// AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (
BOOL
)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return
YES;
}
@end
// main.m
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int
main(
int
argc,
char
*argv[]) {
@autoreleasepool {
return
UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate
class
]));
}
}