Several ideas for IOS to implement long press slip cancellation

Source: Internet
Author: User

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

    1. 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.
    2. 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.
    3. 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

    1. 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.
    2. 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.
    3. 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

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.