iOS Development Outreach-Audio processing (music player 2)

Source: Internet
Author: User
Tags uikit

iOS Development Outreach-Audio processing (music player 2)

Description: This article mainly introduces the construction of the music playing interface.

First, jump

1. Method selection to jump to the music playback interface (1) Use modal jumps (also divided into manual and Automatic) (2) Use Xib and set jump 2. Two methods of analysis can use the modal method, add a controller, let this controller and music play Controller class to associate, off line,  Set the identifier and execute segue in the cell's click event.  Step Description: (1) Drag a new controller into the storyboard, then set and associate with the playing controller class. (2) Set manual jump

(3) Set the identifier of the segue

(3) Jump code processing

The following reasons are not recommended for the use of modal modes:If you want to jump back to the music list screen after selecting a music to jump to the playback interface, the most common practice is to add a button to the music playback controller. When clicked, destroy this controller (dismissed).    However, the controller destroys the music that is playing and then it is gone. And because the layout of the playback interface controller is fixed, the method chosen here is created using Xib.  3. Select the method to create a new xib, corresponding to the music playback controller. The structure of the xib is as follows:Details: The controller only needs to be created once, so lazy loading is recommended, but the player is set as a singleton
////YYMUSICSVIEWCONTROLLER.M//#import"YYMusicsViewController.h"#import"YYMusicModel.h"#import"MJExtension.h"#import"YYMusicCell.h"#import"YYPlayingViewController.h"@interface Yymusicsviewcontroller () @property (nonatomic,strong) Nsarray*musics; @property (nonatomic,strong) Yyplayingviewcontroller * Playingviewcontroller; @end @implementation Yymusicsviewcontroller#pragmamark-Lazy Loading-(Nsarray *) musics{if(_musics==Nil) {_musics=[yymusicmodel Objectarraywithfilename:@"musics.plist"]; }    return_musics;}-(Yyplayingviewcontroller *) playingviewcontroller{  if (_playingviewcontroller==nil) {    _playingviewcontroller=[[Yyplayingviewcontroller alloc]init]; }  return  _playingviewcontroller;} 
Internal details of the 4.xib: (1) Constraints have been implemented for the adaptation of IOS6 and iOS7. (2) Set the music name and the singer's view set to translucent, set the method as follows: set to 30%

Note: Do not set the transparency on the properties panel of the control in the storyboard (so that the child controls in this control are the same transparency). Deprecated Practices: (3) button click to Glow

(4) Setting view hide can save some performance. (Reference Code) (5) in the process of switching the controller, the Setup window cannot be clicked (this is done to prevent the user from multiple consecutive clicks on the song name will appear the problem). 5. Add: The UIView classification is dragged into the project code to facilitate the calculation of the frame Second, the code involvedProvides a common object method interface YYPlayingViewController.h file in the. h file of the playback controller
//   YYPlayingViewController.h<UIKit/UIKit.h>@interface Yyplayingviewcontroller: Uiviewcontroller// Display Controller -(void) show; @end

YYPLAYINGVIEWCONTROLLER.M file

////YYPLAYINGVIEWCONTROLLER.M//#import"YYPlayingViewController.h"@interface Yyplayingviewcontroller ()-(ibaction) exit; @end @implementation Yyplayingviewcontroller#pragmamark-Public Method-(void) show{//1. Disable click events for the entire appUIWindow *window=[UIApplication Sharedapplication].keywindow; Window.userinteractionenabled=NO; //2. Add the Playback interface//set the view size to cover the entire windowSelf.view.frame=Window.bounds; //Setting the view displayself.view.hidden=NO; //add view to the window[window AddSubview:self.view]; //3. Use animations to show the viewself.view.y=Self.view.height; [UIView animatewithduration:0.25animations:^{self.view.y=0; } Completion:^(BOOL finished) {window.userinteractionenabled=YES; }];}#pragmaButton monitoring method inside the mark-//Back button-(ibaction) exit {//1. Disable click events for the entire appUIWindow *window=[UIApplication Sharedapplication].keywindow; Window.userinteractionenabled=NO; //2. Animate hidden View[UIView animatewithduration:0.25animations:^{self.view.y=Window.height; } Completion:^(BOOL finished) {window.userinteractionenabled=YES; //setting view shadowing can save some performanceself.view.hidden=YES; }];} @end

The processing code in the cell's Click event:

 /*  * * cell's Click event  */-(void ) TableView: (UITableView *) TableView Didselectrowatindexpath :(Nsindexpath *) indexpath{ //  Uncheck the line that was clicked   [TableView Deselectrowatindexpath:indexpath Animated:yes];  //  call public method   [Self.playingviewcontroller show] ;  // //  //  [self performseguewithidentifier:@ "music2playing" Sender:nil]; } 

iOS Development Outreach-Audio processing (music player 2)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.