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. Analysis of two different methodsYou can use the modal method to add a controller that associates the controller with the music playback controller class, de-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 Segue identifier (3) Jump code processing is not recommended for the following reasons: When you select a music to jump to the playback interface to play, if you want to jump back to the music list interface, then the most common practice is to add on the music playback controller    a button. 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. Method of SelectionCreate a new xib that corresponds to the music playback controller. The structure of the xib is as follows: Detail: The controller needs to be created only once, so lazy loading is recommended, but the player is set as a singleton
1//2//  YYMUSICSVIEWCONTROLLER.M 3//4  5 #import "YYMusicsViewController.h" 6 #import "YYMusicModel.h" 7 #impor T "MJExtension.h" 8 #import "YYMusicCell.h" 9 #import "YYPlayingViewController.h" @interface Yymusicsviewcontroller () @property (nonatomic,strong) nsarray *musics;13 @property (nonatomic,strong) Yyplayingviewcontroller * playingviewcontroller;14 @end15 @implementation YYMusicsViewController17 #pragma mark-lazy load-(Nsarray *) musics19 {20     if (_musics==nil) {         _musics=[yymusicmodel objectarraywithfilename:@ "musics.plist"];22     }23     Return _musics;24}25-(Yyplayingviewcontroller *) PlayingViewController26 {     if (_playingviewcontroller==nil) {         _playingviewcontroller=[[yyplayingviewcontroller alloc]init];29     }30     return _playingviewcontroller ; 31}
internal details of 4.xib:(1) Constraints have been implemented for the adaptation of IOS6 and iOS7.    (2) Set the music name and the artist's view set to translucent, set the method as follows: Set to 30% Note: Do not set the transparency on the control's properties panel in storyboard (so that the child controls in this control are the same transparency). Deprecated Practices: (3) button click Glow (4) Setting the 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. Supplement: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
1//  YYPLAYINGVIEWCONTROLLER.H2 3 #import <uikit/uikit.h>4 5 @interface Yyplayingviewcontroller: UIVIEWCONTROLLER6//Display Controller 7-(void) show;8 @end

YYPLAYINGVIEWCONTROLLER.M file

 1//2//YYPLAYINGVIEWCONTROLLER.M 3//4 5 #import "YYPlayingViewController.h" 6 7 @interface Yyplayingviewcontrolle R () 8-(ibaction) exit;     9 @end11 @implementation YYPlayingViewController13 #pragma mark-public Method-(void) SHOW15 {16//1. Disable click events for the entire app 17 UIWindow *window=[uiapplication sharedapplication].keywindow;18 window.userinteractionenabled=no;19 20//2. Add Broadcast Put the interface 21//Set the view size to cover the entire window self.view.frame=window.bounds;23//Set view display self.view.hidden=no;25//Put Vie W Added to Window addsubview:self.view];27 [window 28//3. Use animations to show the view self.view.y=self.view.height;30 [Uivie W animatewithduration:0.25 animations:^{31 self.view.y=0;32} completion:^ (BOOL finished) {WINDOW.U     serinteractionenabled=yes;34}];35}36 #pragma mark-button Monitoring method 37//Back button-(ibaction) exit {39//1. Disable click events for the entire app 40 UIWindow *window=[uiapplication sharedapplication].keywindow;41 window.userinteractionenabled=no;42 43//2. Animation hidden View44 [UIView animatewithduration:0.25 animations:^{45 self.view.y=window.height;46} completion:^ (B OOL finished) {window.userinteractionenabled=yes;48//Set view hide to save some performance self.view.hidden=yes;5 0}];51}52 @end

The processing code in the cell's Click event:

1/** 2  *  Cell's Click event 3 */  4-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath 5 {6     //uncheck the line that was clicked 7     [TableView Deselectrowatindexpath:indexpath Animated:yes]; 8      9     // Call public method Ten [Self.playingviewcontroller show];11/////    Execute segue Jump//    [self performseguewithidentifier:@ "Music2playing" sender:nil];14}

iOS Development Outreach-Audio processing (music player 2)

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.