ios延迟的方法列举

2015-12-09  本文已影响26人  飞雨2013

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (IBAction)btnClick:(id)sender {

NSLog(@"laile");

UIAlertView *tempView = [[UIAlertView alloc] initWithTitle:@"" message:@"hello world" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];

[tempView show];

//1

//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

//        [tempView dismissWithClickedButtonIndex:0 animated:YES];

//    });

//    2

[self performSelector:@selector(createTimer:) withObject:tempView afterDelay:3];

}

- (void)createTimer:(UIAlertView *)tempView

{

[tempView dismissWithClickedButtonIndex:0 animated:YES];

}

@end

上一篇 下一篇

猜你喜欢

热点阅读