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 不正确。他会跳转一下有跳转到别的界面,不知道具体原因。。。
-(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 不正确。他会跳转一下有跳转到别的界面,不知道具体原因。。。
相关文章推荐
- IOS中的多线程
- iOS讲解迷惑深入浅出之基础动画-关键帧动画
- 设置NavigationBar标题的颜色
- iOS经典讲解之NSNotification(通知)
- iOS开发开关
- iOS分段控制器
- iOS开发常用的代码
- iOS开发中那些高效常用的宏
- iOS开发:沙盒机制以及利用沙盒存储字符串、数组、字典等数据
- iOS开发 ----- AFNetWorkingSession
- 作业
- iOS开发:图片的异步加载
- iOS_XML与JSON解析
- IOS Alcatraz Xcode6.4安装指南
- 蓝懿iOS培训日志19 SearchBarController
- 【读书笔记】iOS-NSDate
- 【读书笔记】iOS-NSDate
- iOS Xcode重要配置
- iOS开发1-Hello World
- nagios4.1.1 服务端及监控端部署(一)