how to make an image appear everytime when i shake my iphone

Posted by Abhishek on Stack Overflow See other posts from Stack Overflow or by Abhishek
Published on 2011-01-14T05:35:03Z Indexed on 2011/01/14 5:53 UTC
Read the original article Hit count: 197

Filed under:
|

Hello, i have created a shake application in iphone but i am having a problem. I want that when i shake my iphone everytime an image should appear for every shake.Can anybody help how is it possible. This is the code which i have written:

CGRect myImageRect = CGRectMake(110.0f, 70.0f, 220.0f, 380.0f);
//This line is for setting my tick.png image on my image view
    UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
            [myImage setImage:[UIImage imageNamed:@"tick_mark.png"]];
        [self.view addSubview:myImage];

       //animation
        [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:1];
                [myImage setAlpha:0.0];
            [UIView commitAnimations];

        [myImage release];

This is for beginning animations and I have set my image alpha to 0.0 so that my image will disappear. This code is working properly. But I want it so that when I shake my iPhone again my image should reappear for every shake. How is it possible.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c