IOS 项目 小说 1
架构:
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
IOS 项目 小说 1的更多相关文章
- 开源 iOS 项目分类索引大全 - 待整理
开源 iOS 项目分类索引大全 GitHub 上大概600个开源 iOS 项目的分类和介绍,对于你挑选和使用开源项目应该有帮助 系统基础库 Category/Util sstoolkit 一套Cate ...
- ios项目里扒出来的json文件
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0. ...
- 现有iOS项目集成React Native过程记录
在<Mac系统下React Native环境搭建>配置了RN的开发环境,然后,本文记录在现有iOS项目集成React Native的过程,官方推荐使用Cocoapods,项目一开始也是使用 ...
- iOS项目的本地化处理(多国语言)
项目的本地化就是:iOS系统在不同语言环境下自动切换语言,从而实现一个app发布到全世界各个国家的AppStore上. 我们不仅仅需要在iOS项目中做本地化处理,在上架iOS APP的时候,也需要做对 ...
- 在Xcode 6 beta里编译Cocos2d-x iOS项目时失败
转载 在Xcode 6 beta里编译Cocos2d-x iOS项目时可能会失败,提示如下错误: Undefined symbols for architecture i386: "_fwr ...
- phonegap创建的ios项目推送消息出现闪退现象
使用phonegap创建的ios项目,推送消息时,当程序在前台运行或者在后台运行状态下,推送消息过来,可以解析并且跳转: 但是在程序从后台退出的状态下,当消息推送过来的时候,点击通知栏,打开程序,程序 ...
- MVVM 模式下iOS项目目录结构详细说明
➠更多技术干货请戳:听云博客 我们在做项目的时候,会经常用到各种设计模式,最常见的要数 MVC (模型,视图,控制器)了.但是,今天我们要说的是另一种设计模式——MVVM. 所以 MVVM 到底是什么 ...
- WinObjc - 使用iOS项目生成通用Windows应用
Github上一周年的WinObjc项目最近发布了预览版本,终于等到了这一天.WinObjc项目就是Build 2015大会上微软宣布的Project IslandWood项目,致力于将iOS应用快速 ...
- iOS 项目中用到的一些开源库和第三方组件
iOS 项目中用到的一些 iOS 开源库和第三方组件 分享一下我目前所在公司 iOS 项目中用到的一些 iOS 开源库和第三方组件, 感谢开源, 减少了我们的劳动力, 节约了我们大量的时间, 让我们有 ...
随机推荐
- System.SysUtils.TMarshaller 与 System.TMarshal
转自:http://www.cnblogs.com/del/archive/2013/06/10/3130974.html TMarshaller(结构) 基于 TMarshal(是有一大堆的 cla ...
- 2.设计包含 min 函数的栈[StackWithMinValue]
[题目]: 定义栈的数据结构,要求添加一个min函数,能够得到栈的最小元素.要求函数min.push以及pop的时间复杂度都是O(1). [解法一]: 使用一个辅助栈来保存最小元素,其栈顶元素为当前栈 ...
- MySQL数据丢失情况分析
一.存储引擎层面丢失数据 由于在实际项目中,我们往往使用支持事务的InnoDB存储引擎.我们 ...
- Heap:Sunscreen(POJ 3614)
晒太阳 题目大意:一堆牛,为了避免晒太阳会灼烧自己,然后他们自己有自己的防晒指数(一个区间),防晒霜可以提高防晒因数SPF,大了不行小了不行,现在有一桶防晒霜,他们提供一定的SPF,但是最多可以提供k ...
- ios学习总结(2) -- UIButton的使用
原文地址 UIButton的类是一个UIControl子类,它实现了在触摸屏上的按钮.触摸一个按钮拦截事件和动作消息发送到目标对象时,它的挖掘.设定的目标和行动方法都继承自UIControl.这个类提 ...
- [Linux] xargs的- n1参数
起因在对一堆*.tar.gz文件解压缩时,发现tar xvfz *.tar.gz不管用,一查,原来是tar xvfz *.tar.gz会被shell给拆成tar xvfz a.tar.gz b.tar ...
- DOS下常用网络命令技巧
DOS,即使对于许多自称了解计算机的人而言,也是一个比较陌生的词汇.然而,在网络管理过程中,DOS命令却是一个不可逾越的障碍,几乎所有的网络命令都运行在DOS界面.对初级用户而言,掌握一些常用网络命令 ...
- MakeFile中赋值
Makefile 中:= ?= += =的区别 在Makefile中我们经常看到 = := ?= +=这几个赋值运算符,那么他们有什么区别呢?我们来做个简单的实验 新建一个Makefile,内容为 ...
- Ubuntu could not write bytes broken pipe
一.环境变量问题 1 到登录界面的时候,进入命令行模式: alt+ctrl+F1 2 登录 3 修改环境变量(当我输入ls的时候 竟然没有找到命令,然后果断的知道是环境变量的事情,于是改之!) 4 ...
- Android Dev Guides
Android Dev Guides Google Java编程风格指南中文版 英文地址:http://google-styleguide.googlecode.com/svn/trunk/javag ...