Tag:sample Declaration for type api Buttons Online methods relationship
Some summary about the recording button
Some summary of the recording button press and hold the recording, slide up to cancel, slide on the button to continue recording
This demand summed up the idea of the Internet, there are probably the following several
- In Touchesbegan, Touchesmoved, touchesended three methods react by judging the coordinates of the point of the current touch with the relationship of the hot zone range of the button.
- Add a long press gesture, the gesturerecognizerstaebegin of gestures, changed, ended three states to determine the position of the finger at this point and the button relationship, so that there are different reactions.
- Different handling of all several click events of the button, Touchupinside, TouchDown, Touchupoutside, Touchcancel, Touchdragexit, Touchdragenter, The main thing is to listen to the six-click event binding method, as to what each method does is very simple to distinguish from the name.
Comparison of General merits
- Three methods only need to rewrite on it, do not need to go to more declaration of additional methods, simple. However, if the current page has other touch monitoring, it is easy to confuse.
- The first difference is not really small, and the API has been provided well, only need to be processed in different states, but it is easy to conflict with the other gestures of the current page.
- One of the finer ways is to interact with the button itself, without involving other controls. However, you need to listen for 6 button response events, to implement 6 additional methods. It's a little tricky.
Get the current time of recording
You can set the Meteringenabled property.
Get current Recording volume
recoder.updateMeters()recorder.averagePowerForChannel //平均值recorder.peakPowerForChannel //最大值
Setting parameters of the recording device
recorderSettingDic = [AVFormatIDKey: NSNumber(unsignedInt: kAudioFormatMPEG4AAC),AVNumberOfChannelsKey: 2, //录音的声道数,立体声为双声道AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue,AVEncoderBitRateKey : 320000,AVSampleRateKey : 44100.0 //录音器每秒采集的录音样本数]
Additional areas to be aware of
Preferably in the Dealloc method or the Deinit recorder = nil method player = nil (if there is a playback recording)
Several ideas for IOS to implement long press slip cancellation