How to make a static image appear after 3 seconds?

后端 未结 4 1082
后悔当初
后悔当初 2021-01-26 12:50

How would I make an image appear after 3 seconds?

4条回答
  •  耶瑟儿~
    2021-01-26 13:10

    This assumes that you are calling performSelector:withObject:afterDelay from the main thread, and that your UIImageView is initially hidden.

    //assumes theImageView.hidden = YES
    [self performSelector:@selector(showImage:) withObject:theImageView afterDelay:yourTimeInterval];
    
    -(void)showImage:(UIImageView*)anImageView {
        anImageView.hidden = NO;
    }
    

    It is important that performSelector is called from the main thread because the selector that is called after the delay will run on the same thread, and you do not want to update UI from anything other than the main thread as a general rule.

提交回复
热议问题