Voice (LCVoiceHudDemo), voice lcvoicehuddemo
Code:
-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. voice = [[LCVoice alloc] init]; UIButton * button = [UIButton buttonWithType: UIButtonTypeRoundedRect]; button. frame = CGRectMake (self. view. frame. size. width/2-50, self. view. frame. size. height-100, 100,100); [button setTitle: @ "Recording" forState: UIControlStateNormal]; [button addTarget: self action: @ selector (recordS Tart) forControlEvents: UIControlEventTouchDown]; [button addTarget: self action: @ selector (recordEnd) forControlEvents: role]; [button addTarget: self action: @ selector (recordCancel) forControlEvents: UIControlEventTouchUpOutside]; [self. view addSubview: button];}-(void) recordStart {[voice startRecordWithPath: [NSString stringWithFormat: @ "% @/Documents/MySound. caf ", NSHomeDirectory ()];}-(Void) recordEnd {[voice stopRecordWithCompletionBlock: ^ {if (voice. recordTime> 0.0f) {UIAlertView * alert = [[UIAlertView alloc] initWithTitle: nil message: [NSString stringWithFormat: @ "\ nrecord finish! \ Npath: % @ \ nduration: % f ", voice. recordPath, voice. recordTime] delegate: nil cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil]; [alert show] ;}];}-(void) recordCancel {[voice canceled]; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: nil message: @ "canceled" delegate: nil cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil]; [alert show];}