I Can't Shake/Motion on my device

kamlesh shingarakhiya

That's my code.

-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(shake) name:@"shake" object:nil];
    if(event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake)
    {

       // SOMETHING HERE
    }
            NSLog(@"motion Began");
    }
     else
    {
        NSLog(@"Shake Is Over");
    }
}

I want to shake/motion on my device.I used that code but it is not working..

NiravPatel

write down below code...then check

-(BOOL) canBecomeFirstResponder {

return YES;

}

-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event 
{
   //your stuff

}

-(void)viewDidAppear:(BOOL)animated {

[self becomeFirstResponder];

}

-(void)viewDidDisappear:(BOOL)animated {

[self resignFirstResponder];

}

let me know it is working or not!!!

Happy Coding!!!!

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I use my Garmin device in Ubuntu?

分類Dev

Why can't I select cells in my WPF datagrid?

分類Dev

RSelenium: Can't see Browser as I run my Code

分類Dev

I can't trigger my second action on google assistant

分類Dev

I can't make Javascript copy my string as I want it

分類Dev

On my Bluetooth LE device, can I change an attribute of a characteristic on a peripheral device?

分類Dev

I can't use a JS script in my HTML with Vue js

分類Dev

I want to click my list item in random but can't

分類Dev

I can't update my contacts

分類Dev

I can't link my JQuery file to my HTML file

分類Dev

I can't find my branch in github, that i created on git

分類Dev

I can't get authenticated with my api using django

分類Dev

Why can't I use my column alias in WHERE clause?

分類Dev

How can I assign a static IP to just one device on my home network?

分類Dev

Why can't I crash my system with a fork bomb?

分類Dev

I can't fill in the blanks in my code

分類Dev

Why can't I see remote video in my WebRTC app?

分類Dev

Why can't I extend my desktop 12.04 in KDE?

分類Dev

How can I use my Garmin device in Ubuntu?

分類Dev

Why can't I open my txt file in Ubuntu?

分類Dev

I can't change the value of my variable

分類Dev

How can I tell if my Cordova application is running on a simulator or real device?

分類Dev

Javascript - I can't find my mistake.(radio buttons)

分類Dev

Why can't I download my package through packagist?

分類Dev

Why can't I access my objects member variable?

分類Dev

Why can't I run any software I want, on any kind of device?

分類Dev

I can't get an answer out of my C++ program

分類Dev

I can't adjust screen brightness of my laptop anymore

分類Dev

My mouse cursor is moving, but i can't click properly

Related 関連記事

  1. 1

    How can I use my Garmin device in Ubuntu?

  2. 2

    Why can't I select cells in my WPF datagrid?

  3. 3

    RSelenium: Can't see Browser as I run my Code

  4. 4

    I can't trigger my second action on google assistant

  5. 5

    I can't make Javascript copy my string as I want it

  6. 6

    On my Bluetooth LE device, can I change an attribute of a characteristic on a peripheral device?

  7. 7

    I can't use a JS script in my HTML with Vue js

  8. 8

    I want to click my list item in random but can't

  9. 9

    I can't update my contacts

  10. 10

    I can't link my JQuery file to my HTML file

  11. 11

    I can't find my branch in github, that i created on git

  12. 12

    I can't get authenticated with my api using django

  13. 13

    Why can't I use my column alias in WHERE clause?

  14. 14

    How can I assign a static IP to just one device on my home network?

  15. 15

    Why can't I crash my system with a fork bomb?

  16. 16

    I can't fill in the blanks in my code

  17. 17

    Why can't I see remote video in my WebRTC app?

  18. 18

    Why can't I extend my desktop 12.04 in KDE?

  19. 19

    How can I use my Garmin device in Ubuntu?

  20. 20

    Why can't I open my txt file in Ubuntu?

  21. 21

    I can't change the value of my variable

  22. 22

    How can I tell if my Cordova application is running on a simulator or real device?

  23. 23

    Javascript - I can't find my mistake.(radio buttons)

  24. 24

    Why can't I download my package through packagist?

  25. 25

    Why can't I access my objects member variable?

  26. 26

    Why can't I run any software I want, on any kind of device?

  27. 27

    I can't get an answer out of my C++ program

  28. 28

    I can't adjust screen brightness of my laptop anymore

  29. 29

    My mouse cursor is moving, but i can't click properly

ホットタグ

アーカイブ