iOS - App内使用代码退出程序

来源:互联网 发布:java style标签 编辑:程序博客网 时间:2024/06/04 20:09

App内使用代码退出程序

- (void)configUI{    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"Exit", nil];    [alert show];}- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{    NSLog(@"%ld",buttonIndex);    if (buttonIndex == 1) {        [self exitApp];    }}- (void)exitApp{//退出App    UIWindow *window = [UIApplication sharedApplication].delegate.window;//获得窗口    [UIView animateWithDuration:1.0f animations:^{        window.alpha = 0;        window.frame = CGRectMake(SCREEN_WIDTH/2, window.bounds.size.width, 0, 0);    } completion:^(BOOL finished) {        exit(0);//动画完毕退出App    }];}
0 0