蓝懿IOS实战音乐播放器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了蓝懿IOS实战音乐播放器相关的知识,希望对你有一定的参考价值。
今天刘国斌老师教了实战的一个demo,仿写音乐播放器
// 1、 如果在viewcontroller里跳转到别的页面里,另一个viewcontroller是storyboard拖出来的,初始化页面需要用self.stroy 再调用方法,instantiateViewControllerWithIdentifier
// 2、 但是如果在其他的页面不是viewcontroller里再跳转到另一个页面,那个页面也是用stroyboard拖出来的,那么就要用 UIStoryboard 通过自己的mainstoryboard标记“Main”先创建一个对象,在用这个对象去初始化另一个页面
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// 宏定义自动获取的屏幕的尺寸
#define SCREEN_SIZE [UIScreen mainScreen].bounds.size
// 功能实现从第一个页面跳转到tabbarcontroller
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *sc=[[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
sc.pagingEnabled=YES;
for (int i=0; i<5; i++) {
UIImageView *iv=[[UIImageViewalloc]initWithFrame:CGRectMake(i*SCREEN_SIZE.width, 0, SCREEN_SIZE.width, SCREEN_SIZE.height)];
iv.image=[UIImage imageNamed:[NSStringstringWithFormat:@"Welcome_3.0_%d.jpg",i+1]];
[sc addSubview:iv];
}
CGRect bnFram=CGRectMake(0, 0, SCREEN_SIZE.width, SCREEN_SIZE.height);
UIButton *bn=[[UIButton alloc]initWithFrame:bnFram];
[bn addTarget:self action:@selector(moo) forControlEvents:UIControlEventTouchUpInside];
[sc addSubview:bn];
sc.delegate=self;
// 考虑到屏幕尺寸适配问题,这里的内容contentSize取动态的
sc.contentSize=CGSizeMake(5*SCREEN_SIZE.width, 667);
[self.view addSubview:sc];
}
-(void)moo{
tabONe *ta1=[tabONe new];
ta1.view.backgroundColor=[UIColor colorWithRed:.5 green:.5 blue:.6 alpha:.7];
[email protected]"原谅我这一生放荡不羁";
UINavigationController *nv1=[[UINavigationControlleralloc]initWithRootViewController:ta1];
[email protected]"我的音乐";
nv1.tabBarItem.image=[UIImage imageNamed:@"tabbar_item_my_music.png"];
tabTwo *ta2=[tabTwo new];
ta2.view.backgroundColor=[UIColor redColor];
[email protected]"辣么屌";
UINavigationController *nv2=[[UINavigationControlleralloc]initWithRootViewController:ta2];
[email protected]"网络";
nv2.tabBarItem.image=[UIImage imageNamed:@"tabbar_item_selected"];
tabThree *ta3=[tabThree new];
[email protected]"没文化,读书";
ta3.view.backgroundColor=[UIColor blueColor];
UINavigationController *nv3=[[UINavigationControlleralloc]initWithRootViewController:ta3];
[email protected]"本地";
nv3.tabBarItem.image=[UIImage imageNamed:@"tabbar_item_store_selected.png"];
tabFour *ta4=[tabFour new];
[email protected]"多么痛的领悟";
ta4.view.backgroundColor=[UIColor greenColor];
UINavigationController *nv4=[[UINavigationControlleralloc]initWithRootViewController:ta4];
[email protected]"更多";
nv4.tabBarItem.image=[UIImage imageNamed:@"tabbar_item_more.png"];
UITabBarController *tabBar=[[UITabBarController alloc]init];
[email protected][nv1,nv2,nv3,nv4];
[self presentViewController:tabBar animated:YES completion:nil];
}
以上是关于蓝懿IOS实战音乐播放器的主要内容,如果未能解决你的问题,请参考以下文章
Java爬虫实战:Jsoup+WebClient实现音乐爬取~