1、
//
// AppDelegate.h
// novel_example
//
// Created by beifeng on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CategoryViewController.h"
#import "PlayViewController.h"
#import "TimerViewController.h"
#import "AboutUsViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UIWindow *window;
//button declare
UIButton *btn1;
UIButton *btn2;
UIButton *btn3;
UIButton *btn4;
//nav
UINavigationController *nav1;
UINavigationController *nav2;
UINavigationController *nav3;
UINavigationController *nav4;
//4 define uiviewcontroller
CategoryViewController *categoryView;
PlayViewController *playView;
TimerViewController *timerView;
AboutUsViewController *aboutUsView;
UIView *viewToolBar;
UIView *v;
}
@property (strong, nonatomic) UIWindow *window;
@end
2、=====================================================================
//
// AppDelegate.m
// novel_example
//
// Created by beifeng on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window = _window;
- (void)dealloc
{
[_window release];
[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.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
//self.window.rootViewController = self.viewController;
v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
v.backgroundColor = [UIColor clearColor];
[self.window addSubview:v];
[v release];
categoryView = [[CategoryViewController alloc]init];
categoryView.view.frame = CGRectMake(0, 0, 320, 436);
nav1 = [[UINavigationController alloc]initWithRootViewController:categoryView];
[v addSubview:nav1.view];
viewToolBar = [[UIView alloc]initWithFrame:CGRectMake(0, 418, 320, 47)];
viewToolBar.backgroundColor = [UIColor clearColor];
[_window addSubview:viewToolBar];
[viewToolBar release];
UIImageView *viewToolBarImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 47)];
viewToolBarImg.image = [UIImage imageNamed:@"首页_按钮底图.png"];
[viewToolBar addSubview:viewToolBarImg];
[viewToolBarImg release];
//category view
btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame = CGRectMake(30, 5, 51, 37);
btn1.tag =1;
[btn1 setAdjustsImageWhenDisabled:YES];
[btn1 setBackgroundImage:[UIImage imageNamed:@"目录.png"] forState:UIControlStateNormal];
[btn1 addTarget:self action:@selector(categoryAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btn1];
//play view
btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
btn2.frame = CGRectMake(94, 5, 51, 37);
btn2.tag =2;
[btn2 setAdjustsImageWhenDisabled:YES];
[btn2 setBackgroundImage:[UIImage imageNamed:@"播放.png"] forState:UIControlStateNormal];
[btn2 addTarget:self action:@selector(playAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btn2];
//timer
btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
btn3.frame = CGRectMake(161, 5, 51, 37);
btn3.tag =3;
[btn3 setAdjustsImageWhenDisabled:YES];
[btn3 setBackgroundImage:[UIImage imageNamed:@"定时.png"] forState:UIControlStateNormal];
[btn3 addTarget:self action:@selector(timerAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btn3];
//aboutus
btn4 = [UIButton buttonWithType:UIButtonTypeCustom];
btn4.frame = CGRectMake(228, 5, 51, 37);
btn4.tag =4;
[btn4 setAdjustsImageWhenDisabled:YES];
[btn4 setBackgroundImage:[UIImage imageNamed:@"关于.png"] forState:UIControlStateNormal];
[btn4 addTarget:self action:@selector(aboutusAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btn4];
[self.window makeKeyAndVisible];
return YES;
}
#pragma mark ----------category action method -----------------
-(void)categoryAction{
NSLog(@"categoryAction");
}
#pragma mark ----------playAction method -----------------
-(void)playAction{
NSLog(@"playAction");
}
#pragma mark ----------timerAction method -----------------
-(void)timerAction{
NSLog(@"timerAction");
}
#pragma mark ----------aboutusAction method -----------------
-(void)aboutusAction{
NSLog(@"aboutusAction");
}
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
@end