Wednesday, May 22, 2013

UIApplication applicationSupportsShakeToEdit example ios


[UIApplication applicationSupportsShakeToEdit]

A Boolean value that determines whether shaking the device displays the undo-redo user interface.
@property(nonatomic) BOOL applicationSupportsShakeToEdit
Discussion of [UIApplication applicationSupportsShakeToEdit]
The default value is YES. Set the property to NO if you don’t want your application to display the Undo and Redo buttons when users shake the device.
Example of [UIApplication applicationSupportsShakeToEdit]
- (void)applicationDidFinishLaunching:(UIApplication *)application {

    application.applicationSupportsShakeToEdit = YES;

    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}
Example of [UIApplication applicationSupportsShakeToEdit]
- (void)viewDidLoad {
    [super viewDidLoad];

    //disable built-in undo
    [UIApplication sharedApplication].applicationSupportsShakeToEdit = NO;

    showingAlertView = NO;

    [UIAccelerometer sharedAccelerometer].delegate = self; 
    [UIAccelerometer sharedAccelerometer].updateInterval = kUpdateInterval;

    //set initial undo text
    self.previousText = textview.text;
}

Example of [UIApplication applicationSupportsShakeToEdit]
/**
 * This is main kick off after the app inits, the views and Settings are setup here.
 */
- (void)applicationDidFinishLaunching:(UIApplication *)application
{ 
 application.applicationSupportsShakeToEdit = YES;
 
 [window addSubview:viewController.view];
 [window makeKeyAndVisible];
 
 [ super applicationDidFinishLaunching:application ];
}