藍懿IOS實戰音樂播放器

來源:互聯網
上載者:User

標籤:

 今天劉國斌老師教了實戰的一個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實戰音樂播放器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.