架构:
logo: logo标识(在image文件夹中修改某图片名称为icon)
default: 默认页面的启动效果(在image文件夹中修改某图片名称为Default)
image:存放图片(根目录下)
4个UIViewController: CategoryViewController, PlayViewController, TimerViewController , AboutUsViewController
* CategoryViewController(目录)
tableview data
* PlayViewController(播放)
* TimerViewController(定时)
* AboutUsViewController(关于)
AppDelegate : start category module(程序开始启动目录view)
5.audio
*import frameworks: audioltoolbox.frameword & avfoundation.framework
AppDelegate.h
//
// AppDelegate.h
// novel_example
//
// Created by chenzg 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 *btnCategory;
UIButton *btnPlay;
UIButton *btnTimer;
UIButton *btnAboutUs; //nav
UINavigationController *navCategory;
UINavigationController *navPlay;
UINavigationController *navTimer;
UINavigationController *navAboutUs; //4 define uiviewcontroller
CategoryViewController *categoryView;
PlayViewController *playView;
TimerViewController *timerView;
AboutUsViewController *aboutUsView; UIView *viewToolBar; UIView *viewContent; }
@property (strong, nonatomic) UIWindow *window; @end
AppDelegate.m
//
// AppDelegate.m
// novel_example
//
// Created by chenzg 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; viewContent = [[UIView alloc]initWithFrame:CGRectMake(, , , )];
viewContent .backgroundColor = [UIColor clearColor];
[self.window addSubview:viewContent ];
[viewContent release]; categoryView = [[CategoryViewController alloc]init];
categoryView.view.frame = CGRectMake(, , , );
navCategory = [[UINavigationController alloc]initWithRootViewController:categoryView];
[viewContent addSubview:navCategory.view]; viewToolBar = [[UIView alloc]initWithFrame:CGRectMake(, , , )];
viewToolBar.backgroundColor = [UIColor clearColor];
[_window addSubview:viewToolBar];
[viewToolBar release]; UIImageView *viewToolBarImg = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
viewToolBarImg.image = [UIImage imageNamed:@"首页_按钮底图.png"];
[viewToolBar addSubview:viewToolBarImg];
[viewToolBarImg release]; //category view btnCategory = [UIButton buttonWithType:UIButtonTypeCustom];
btnCategory.frame = CGRectMake(, , , );
btnCategory.tag =;
[btnCategory setAdjustsImageWhenDisabled:YES];
[btnCategory setBackgroundImage:[UIImage imageNamed:@"目录.png"] forState:UIControlStateNormal];
[btnCategory addTarget:self action:@selector(categoryAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btnCategory]; //play view btnPlay = [UIButton buttonWithType:UIButtonTypeCustom];
btnPlay.frame = CGRectMake(, , , );
btnPlay.tag =;
[btnPlay setAdjustsImageWhenDisabled:YES];
[btnPlay setBackgroundImage:[UIImage imageNamed:@"播放.png"] forState:UIControlStateNormal];
[btnPlay addTarget:self action:@selector(playAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btnPlay]; //timer btnTimer = [UIButton buttonWithType:UIButtonTypeCustom];
btnTimer.frame = CGRectMake(, , , );
btnTimer.tag =;
[btnTimer setAdjustsImageWhenDisabled:YES];
[btnTimer setBackgroundImage:[UIImage imageNamed:@"定时.png"] forState:UIControlStateNormal];
[btnTimer addTarget:self action:@selector(timerAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btnTimer]; //aboutus
btnAboutUs = [UIButton buttonWithType:UIButtonTypeCustom];
btnAboutUs.frame = CGRectMake(, , , );
btnAboutUs.tag =;
[btnAboutUs setAdjustsImageWhenDisabled:YES];
[btnAboutUs setBackgroundImage:[UIImage imageNamed:@"关于.png"] forState:UIControlStateNormal];
[btnAboutUs addTarget:self action:@selector(aboutusAction) forControlEvents:UIControlEventTouchDown];
[viewToolBar addSubview:btnAboutUs]; [self.window makeKeyAndVisible];
return YES;
} #pragma mark ----------category action method ----------------- -(void)categoryAction{ NSLog(@"categoryAction");
[btnCategory setBackgroundImage:[UIImage imageNamed:@"目录.png"] forState:UIControlStateNormal];//选择的效果
[btnPlay setBackgroundImage:[UIImage imageNamed:@"播放.png"] forState:UIControlStateNormal];//未选择的效果
[btnTimer setBackgroundImage:[UIImage imageNamed:@"定时.png"] forState:UIControlStateNormal];//未选择的效果
[btnAboutUs setBackgroundImage:[UIImage imageNamed:@"关于.png"] forState:UIControlStateNormal];//未选择的效果 if ((navCategory.view.hidden =YES)) {
//
navCategory.view.hidden = NO;
navPlay.view.hidden = YES;
navTimer.view.hidden = YES;
navAboutUs.view.hidden = YES;
} }
#pragma mark ----------playAction method ----------------- -(void)playAction{
NSLog(@"playAction");
if (playView == nil) {
//
playView = [[PlayViewController alloc]init];
playView.view.frame = CGRectMake(, , , );
navPlay = [[UINavigationController alloc]initWithRootViewController:playView];
[viewContent addSubview:navPlay.view];
} [btnCategory setBackgroundImage:[UIImage imageNamed:@"目录.png"] forState:UIControlStateNormal];//未选择的效果
[btnPlay setBackgroundImage:[UIImage imageNamed:@"播放.png"] forState:UIControlStateNormal];//选择的效果
[btnTimer setBackgroundImage:[UIImage imageNamed:@"定时.png"] forState:UIControlStateNormal];//未选择的效果
[btnAboutUs setBackgroundImage:[UIImage imageNamed:@"关于.png"] forState:UIControlStateNormal];//未选择的效果 if ((navPlay.view.hidden =YES)) {
//
navPlay.view.hidden = NO;
navCategory.view.hidden = YES;
navTimer.view.hidden = YES;
navAboutUs.view.hidden = YES;
} } #pragma mark ----------timerAction method ----------------- -(void)timerAction{ NSLog(@"timerAction"); if (timerView == nil) {
//
timerView = [[TimerViewController alloc]init];
timerView.view.frame = CGRectMake(, , , );
navTimer = [[UINavigationController alloc]initWithRootViewController:timerView];
[viewContent addSubview:navTimer.view];
} [btnCategory setBackgroundImage:[UIImage imageNamed:@"目录.png"] forState:UIControlStateNormal];//未选择的效果
[btnPlay setBackgroundImage:[UIImage imageNamed:@"播放.png"] forState:UIControlStateNormal];//未选择的效果
[btnTimer setBackgroundImage:[UIImage imageNamed:@"定时.png"] forState:UIControlStateNormal];//选择的效果
[btnAboutUs setBackgroundImage:[UIImage imageNamed:@"关于.png"] forState:UIControlStateNormal];//未选择的效果 if ((navTimer.view.hidden =YES)) {
//
navTimer.view.hidden = NO;
navCategory.view.hidden = YES;
navPlay.view.hidden = YES;
navAboutUs.view.hidden = YES;
} } #pragma mark ----------aboutusAction method ----------------- -(void)aboutusAction{ NSLog(@"aboutusAction");
if (aboutUsView == nil) {
//
aboutUsView = [[AboutUsViewController alloc]init];
aboutUsView.view.frame = CGRectMake(, , , );
navAboutUs = [[UINavigationController alloc]initWithRootViewController:aboutUsView];
[viewContent addSubview:nav4.view];
} [btnCategory setBackgroundImage:[UIImage imageNamed:@"目录.png"] forState:UIControlStateNormal];//未选择的效果
[btnPlay setBackgroundImage:[UIImage imageNamed:@"播放.png"] forState:UIControlStateNormal];//未选择的效果
[btnTimer setBackgroundImage:[UIImage imageNamed:@"定时.png"] forState:UIControlStateNormal];//未选择的效果
[btnAboutUs setBackgroundImage:[UIImage imageNamed:@"关于.png"] forState:UIControlStateNormal];//选择的效果 if ((navAboutUs.view.hidden =YES)) {
//
navAboutUs.view.hidden = NO;
navCategory.view.hidden = YES;
navPlay.view.hidden = YES;
navTimer.view.hidden = YES;
} }
- (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
CategoryViewController.h
//
// CategoryViewController.h
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import <UIKit/UIKit.h> @interface CategoryViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>
{
UITableView *table;
NSArray *arr;
} @end
CategoryViewController.m
//
// CategoryViewController.m
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import "CategoryViewController.h"
#import "CustomCell.h"
#import "PlayViewController.h" @implementation CategoryViewController #pragma mark -------UITableViewDelegate method(行高): - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return ; } #pragma mark ---点击某行触发的方法 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { PlayViewController *play = [[PlayViewController alloc]init];
//
play.arr_objindex = indexPath.row; [self.navigationController pushViewController:play animated:YES];
} #pragma mark UITableViewDataSource method: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell"; CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease]; [cell setTheImage:[UIImage imageNamed:@"条纹.png"]]; //title
UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(, , , )];
lbl.backgroundColor = [UIColor clearColor];
lbl.tag = indexPath.row;
lbl.textColor = [UIColor blackColor];
lbl.text = [arr objectAtIndex:indexPath.row];//arry indexPath.row
[cell addSubview:lbl]; } cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return ;//[arr count];//array count
} - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;{
return ; } - (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use.
} #pragma mark - View lifecycle /*
87 // Implement loadView to create a view hierarchy programmatically, without using a nib.
88 - (void)loadView
89 {
90 }
91 */ -(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
self.navigationController.navigationBar.hidden = YES; }
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden = YES; UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
imageView.image = [UIImage imageNamed:@"Default.png"];
[self.view addSubview:imageView];
[imageView release]; arr = [[NSArray alloc]initWithObjects:@"秦朝帝王史话第一讲",@"秦朝帝王史话第二讲",@"秦朝帝王史话第三讲",@"秦朝帝王史话第四讲",@"秦朝帝王史话第五讲",@"秦朝帝王史话第六讲",@"秦朝帝王史话第七讲",@"秦朝帝王史话第八讲",@"秦朝帝王史话第九讲",@"秦朝帝王史话第十讲",@"秦朝帝王史话第十一讲",@"秦朝帝王史话第十二讲", nil]; table = [[UITableView alloc]initWithFrame:CGRectMake(, , , ) style:UITableViewStylePlain];
table.scrollEnabled = YES;
table.delegate = self;
table.dataSource = self;
table.backgroundColor = [UIColor clearColor]; table.separatorStyle = UITableViewCellSeparatorStyleNone;// 去掉cell的线
table.indicatorStyle = UIScrollViewIndicatorStyleWhite; [self.view addSubview:table]; } - (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
} - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
} @end
PlayViewController.h
//
// PlayViewController.h
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h> @interface PlayViewController : UIViewController<AVAudioPlayerDelegate>
{
AVAudioPlayer *player;
UISlider *mySlider;
UISlider *mySlider1;
SystemSoundID soundID; NSInteger arr_objindex;
NSString *str; } @property (nonatomic,retain)AVAudioPlayer *player;
@property (nonatomic,retain)UISlider *mySlider;
@property (nonatomic,retain)UISlider *mySlider1;
@property (nonatomic) NSInteger arr_objindex; -(IBAction)sliderChange1:(id)sender; @end
PlayViewController.m
//
// PlayViewController.m
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import "PlayViewController.h" @implementation PlayViewController
@synthesize player,mySlider,mySlider1,arr_objindex; -(void)viewWillAppear:(BOOL)animated{ self.navigationController.navigationBar.hidden = YES; } -(IBAction)sliderChange1:(id)sender{ NSLog(@"sliderChange"); UISlider *slider = (UISlider *)sender;
player.currentTime = slider.value * player.duration;
NSLog(@"%f",player.currentTime); NSString *str1 = [NSString stringWithFormat:@"%f",player.currentTime];
UILabel *sliderLbl = [[UILabel alloc]initWithFrame:CGRectMake(, , , )];
sliderLbl.backgroundColor = [UIColor clearColor];
sliderLbl.textColor = [UIColor redColor];
sliderLbl.text = str1;
sliderLbl.font = [UIFont systemFontOfSize:];
[self.view addSubview:sliderLbl];
[sliderLbl release]; } - (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use.
} #pragma mark - View lifecycle /*
52 // Implement loadView to create a view hierarchy programmatically, without using a nib.
53 - (void)loadView
54 {
55 }
56 */ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad]; UIImageView *bottomImg = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
bottomImg.image =[UIImage imageNamed:@"底图.png"];
[self.view addSubview:bottomImg];
[bottomImg release]; UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
img.image =[UIImage imageNamed:@"首页_时间与进度轴.png"];
[self.view addSubview:img];
[img release]; UILabel *leftLbl = [[UILabel alloc]initWithFrame:CGRectMake(, , , )];
leftLbl.backgroundColor =[UIColor clearColor];
leftLbl.text =@"-";
leftLbl.textColor = [UIColor yellowColor];
[self.view addSubview:leftLbl];
[leftLbl release]; UILabel *rightLbl = [[UILabel alloc]initWithFrame:CGRectMake(, , , )];
rightLbl.backgroundColor =[UIColor clearColor];
rightLbl.textColor =[UIColor yellowColor];
rightLbl.text = @"+";
[self.view addSubview:rightLbl];
[rightLbl release]; mySlider = [[UISlider alloc]initWithFrame:CGRectMake(, , , )];
mySlider.backgroundColor =[UIColor clearColor];
mySlider.maximumValue = 50.0;
mySlider.minimumValue = 10.0;
mySlider.value = 10.0;
[mySlider setMaximumTrackImage:[UIImage imageNamed:@"max.png"] forState:UIControlStateNormal];
[mySlider setMinimumTrackImage:[UIImage imageNamed:@"min.png"] forState:UIControlStateNormal];
[mySlider setThumbImage:[UIImage imageNamed:@"thumb.png"] forState:UIControlStateNormal];
[mySlider addTarget:self action:@selector(sliderChange1:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:mySlider]; mySlider1 = [[UISlider alloc]initWithFrame:CGRectMake(, , , )];
mySlider1.backgroundColor = [UIColor clearColor];
mySlider1.maximumValue = 50.0;
mySlider1.minimumValue = 10.0;
mySlider1.value = 22.0;
[mySlider1 setMaximumTrackImage:[UIImage imageNamed:@"max.png"] forState:UIControlStateNormal];
[mySlider1 setMinimumTrackImage:[UIImage imageNamed:@"min.png"] forState:UIControlStateNormal];
[mySlider1 setThumbImage:[UIImage imageNamed:@"thumb.png"] forState:UIControlStateNormal]; //UIControlEventValueChanged:值在变化 [mySlider1 addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:mySlider1]; switch (arr_objindex) {
case :
//
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break; case :
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break;
case :
str = @"";
break; default:
break;
} if (player ==nil) {
// NSError *error = nil;
NSString *path = [[NSBundle mainBundle]pathForResource:str ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:path]; player = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
player.delegate = self; } [player prepareToPlay];
[player play]; [player setVolume:5.0]; }
#pragma mark -----------------control audio
-(void)sliderChange:(id)sender{ UISlider *slider = (UISlider *)sender; NSLog(@"%f",slider.value);
[player setVolume:slider.value]; } - (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
} - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
} @end
TimerViewController.h
//
// TimerViewController.h
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import <UIKit/UIKit.h>
#import "PlayViewController.h"
@interface TimerViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>
{
UITableView *table;
NSArray *arr;
UILabel *timerLbl;
UISwitch *switch_;
PlayViewController *playView; } @property(nonatomic,retain)UISwitch *switch_;
-(IBAction)switchChange:(id)sender; @end
TimerViewController.m
//
// TimerViewController.m
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import "TimerViewController.h"
#import "CustomCell.h"
@implementation TimerViewController @synthesize switch_;
@synthesize player;
-(IBAction)switchChange:(id)sender{ NSLog(@"switch change");
UISwitch *mySwitch = (UISwitch *)sender;
BOOL setting = mySwitch.isOn;//open
[switch_ setOn:setting animated:YES]; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use.
} #pragma mark - View lifecycle /*
45 // Implement loadView to create a view hierarchy programmatically, without using a nib.
46 - (void)loadView
47 {
48 }
49 */
#pragma mark -------UITableViewDelegate method(行高): - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return ; } #pragma mark ---点击某行触发的方法 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didselect");
switch (indexPath.row) {
case :
//
playView.player.currentTime = ;
if (playView.player.duration==) {
//
[playView.player stop];
}
break; default:
break;
} } #pragma mark UITableViewDataSource method: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell"; CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease]; [cell setTheImage:[UIImage imageNamed:@"条纹.png"]]; if (indexPath.row ==) {
// }else{ //title
UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(, , , )];
lbl.backgroundColor = [UIColor clearColor];
lbl.tag = indexPath.row;
lbl.textColor = [UIColor blackColor];
lbl.text = [arr objectAtIndex:indexPath.row];//arry indexPath.row
[cell addSubview:lbl]; } } cell.selectionStyle = UITableViewCellSelectionStyleNone;
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return ;//[arr count];//array count
} - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;{
return ; }
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
self.navigationController.navigationBar.hidden = YES; }
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad]; UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
imageView.image = [UIImage imageNamed:@"Default.png"];
[self.view addSubview:imageView];
[imageView release]; arr = [[NSArray alloc]initWithObjects:@"",@"10分钟",@"20分钟",@"30分钟",@"40分钟",@"50分钟",@"60分钟",nil]; table = [[UITableView alloc]initWithFrame:CGRectMake(, , , ) style:UITableViewStylePlain];
table.scrollEnabled = YES;
table.delegate = self;
table.dataSource = self;
table.backgroundColor = [UIColor clearColor]; table.separatorStyle = UITableViewCellSeparatorStyleNone;// 去掉cell的线
table.indicatorStyle = UIScrollViewIndicatorStyleWhite; [self.view addSubview:table]; switch_ = [[UISwitch alloc]initWithFrame:CGRectMake(, , , )];
switch_.backgroundColor =[UIColor clearColor];
[switch_ addTarget:self action:@selector(switchChange:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:switch_];
} - (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
} - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
} @end
AboutUsViewController.h
//
// AboutUsViewController.h
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import <UIKit/UIKit.h> @interface AboutUsViewController : UIViewController @end
AboutUsViewController.m
//
// AboutUsViewController.m
// novel_example
//
// Created by chenzg on 3/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import "AboutUsViewController.h" @implementation AboutUsViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use.
} #pragma mark - View lifecycle /*
33 // Implement loadView to create a view hierarchy programmatically, without using a nib.
34 - (void)loadView
35 {
36 }
37 */ /*
40 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
41 - (void)viewDidLoad
42 {
43 [super viewDidLoad];
44 }
45 */ - (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
} - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
} @end CustomCell.h //
// CustomCell.h
// novel_example
//
// Created by chenzg on 4/7/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import <UIKit/UIKit.h> @interface CustomCell : UITableViewCell
{
UIImageView *imageView; } -(void)setTheImage:(UIImage *)icon; @end
CustomCell.m
//
// CustomCell.m
// novel_example
//
// Created by chenzg on 4/7/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
// #import "CustomCell.h" @implementation CustomCell #pragma mark---------setTheImage------ -(void)setTheImage:(UIImage *)icon{ imageView = [[UIImageView alloc]initWithImage:icon];
imageView.frame = CGRectMake(, , , );
[self.contentView addSubview:imageView]; } #pragma mark ------去除cell的背景色 -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self== [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//cell background kill [self.contentView setBackgroundColor:[UIColor clearColor]]; } return self; } -(void)setSelected:(BOOL)selected animated:(BOOL)animated{ [super setSelected:selected animated:animated]; if (selected == YES) {
//
imageView.alpha =;//cell被图片覆盖 }else{ imageView.alpha =.;//cell透明
} } - (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use.
} #pragma mark - View lifecycle /*
68 // Implement loadView to create a view hierarchy programmatically, without using a nib.
69 - (void)loadView
70 {
71 }
72 */ /*
75 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
76 - (void)viewDidLoad
77 {
78 [super viewDidLoad];
79 }
80 */ - (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
} - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
} @end