Do something after a certain time after button clicked

后端 未结 2 900
予麋鹿
予麋鹿 2021-01-24 01:32

I am trying to have an object disappear from the view after a certain time after a button is tapped. I\'m a little confused with how to get the object to do something a certain

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-24 02:24

    In your button pressed method you can use:

    [self performSelector:@selector(myMethod) withObject:nil afterDelay:3];
    

    And declare method with logic you want to run:

    -(void) myMethod
    {
        //TODO: your logic goes here
    }
    

    You can even pass parameter to your method if you want (withObject argument).

提交回复
热议问题