#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (retain, nonatomic) UIWindow *window;
@end
#import "AppDelegate.h"
#import "MainViewController.h"
@implementation AppDelegate
- (void)dealloc
{
[_window release];
_window = nil;
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
MainViewController *main = [[MainViewController alloc] init];
main.view.backgroundColor = [UIColor magentaColor];
[_window setRootViewController:main];
[main release];
[self.window makeKeyAndVisible];
return YES;
}
#import <UIKit/UIKit.h>
@interface MainViewController : UIViewController
@property(retain, nonatomic) UIButton *button;
@end
#import "MainViewController.h"
@interface MainViewController ()
@end
@implementation MainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
int n;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 4; j++) {
_button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
_button.frame = CGRectMake(40 + 60 * j, 70 + 70 * i, 50, 50);
_button.tag = n;
n ++;
[_button setTitle:@"