您的位置:首页 > 移动开发 > IOS开发

iOS 退出系统,返回到登陆界面

2015-09-24 20:54 543 查看
//点击退出系统按钮时

-(void)didClickLogoutBtn{

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"您确定要退出吗"delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"退出" otherButtonTitles:nil, nil];

[actionSheet showInView:self.view];

}

//实现UIActionSheet的代理

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

if (buttonIndex == 0) {

//退出系统,返回登陆界面(从storyboard里加载的)

UIStoryboard *mainStory = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

//storyboard里的ID

UIViewController *vc = [mainStory instantiateViewControllerWithIdentifier:@"Login"];

//设置当前窗口的根控制器

self.view.window.rootViewController =
vc;

}

}

注意:UIWindow *window = [UIApplication sharedApplication].keyWindow;

通过获取这个window,然后改变window.rootViewController 不正确。他会跳转一下有跳转到别的界面,不知道具体原因。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: