performSelector:withObject:afterDelay: not making call

前端 未结 4 1989
情书的邮戳
情书的邮戳 2021-02-19 00:45

in a method, i want to call a method after n seconds:

    self.toolBarState = [NSNumber numberWithInt:1];
    [self changeButtonNames];
    [self drawMap];
    [         


        
4条回答
  •  面向向阳花
    2021-02-19 01:14

    Try using:

    -(void) select {   
        [self changeButtonNames];
        [self drawMap];
        [self performSelectorOnMainThread:@selector(showActionSheet) withObject:nil waitUntilDone:YES];
    }
    

    -performSelector:withObject:afterDelay: schedules a timer on the same thread to call the selector after the passed delay.

    Maybe this will work for you:

    -(void) select {   
        [self changeButtonNames];
        [self drawMap];
        [self performSelectorOnMainThread:@selector(someA) withObject:nil waitUntilDone:YES];
    }
    
    -(void)someA {
        [self performSelector:@selector(showActionSheet) withObject:nil afterDelay:2];
    }
    

提交回复
热议问题