When we use it, do we feel that the shake function is dazzling? Is it difficult to implement it?
In fact, otherwise, these are all encapsulated by Apple, which provides a very simple portal for me.
These methods are available in uiresponder:
-(Void) motionbegan :( uieventsubtype) motion withevent :( uievent *) event {nslog (@ "began");}-(void) motioncancelled :( uieventsubtype) motion withevent :( uievent *) event {nslog (@ "cancel");}-(void) motionended :( uieventsubtype) motion withevent :( uievent *) event {nslog (@ "end ");}
These methods can be used directly in the subclass of uiviewcontroller, because uiviewcontroller also inherits from uiresponder.
In implementation, the viewcontroller class must support the shake function.
Code:
[[Uiapplication sharedapplication] setapplicationsupportsshaketoedit: Yes]; [self becomefirstresponder];
-(Bool) canbecomefirstresponder {
Return yes;
}
OK. These two codes support this function.