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 开源库和第三方组件, 感谢开源, 减少了我们的劳动力, 节约了我们大量的时间, 让我们有 ...
随机推荐
- jquery博客收集的IE6中CSS常见BUG全集及解决方案
今天的样式调的纠结,一会这边一会那么把jquery博客折腾的头大,浏览器兼容性.晚上闲着收集一些常见IE6中的BUG 3像素问题及解决办法 当使用float浮动容器后,在IE6下会产生3px的空隙,有 ...
- Smarty s01
复习面向过程中,如何输出显示变量的内容 01.php 第一个版本,使用三个文件来输出html 1.访问文件 2.类MyTpl.class.php 3.一个html模板文件 课堂练习第一个版本 第二个版 ...
- SSHPASS支持从命令行输入密码
参考:http://www.2cto.com/os/201307/227911.html 手动下载地址:http://sourceforge.net/projects/sshpass/ 安装示例: w ...
- 【转】Linux Shell脚本调试技术
本文转载自:https://www.ibm.com/developerworks/cn/linux/l-cn-shell-debug/ Shell脚本调试技术 本文全面系统地介绍了shell脚本调试技 ...
- 如何提高cocos2d-x-spine骨骼动画加载速度
下面分2点来说: 1. 时间消耗点:io和现场解析 解决方案:加载过的骨骼动画就不要每次重新加载,不要每次都去加载json文件和atlas,我推荐使用 static CCSkeletonAnimati ...
- ubuntu 下wireshark 软件安装与使用
在ubuntu下,使用wireshark也是很有必要的.虽然可以使用tcpdump等工具. ubuntu:11.10 1. sudo apt-get install wireshark ...
- Android开发之onClick事件的三种写法
package a.a; import android.app.Activity; import android.os.Bundle; import android.view.View; import ...
- SQL with as
姓名 课程 分数 张三 语文 张三 数学 张三 物理 李四 语文 李四 数学 李四 物理 先看下面一个嵌套的查询语句 ) 上面的查询语句使用了一个子查询.虽然这条SQL语句并不复杂,但如果嵌套的层次过 ...
- sql server 本地复制订阅 实现数据库服务器 读写分离
再前段echosong 写了一遍关于mysql 数据同步实现业务读写分离的文章,今天咱们来看下SQL Server的复制订阅实现数据的读写分离 比起mysql的复制,SQL server 复制相对强大 ...
- PHP5.3 goto操作符介绍
goto操作符是PHP5.+后新增功能,用来跳转到程序的另一位置:用法很简单:goto后面带上目标位置的标志,在目标位置上用目标名加冒号标记如下: <?php goto a; echo 'aaa ...