iOS 跳转出现attempt to dismiss modal view controller whose view does not currently ……的解决方案

今天在设置修改密码成功进行跳转到登录页面重新登录的时候,我写的原代码是:

[self dismissViewControllerAnimated:YES completion:nil];

[UIApplication sharedApplication].keyWindow.rootViewController = [[loginViewController alloc]init];

于是出现了在本页面跳到登录页面,然后又切回到本页面的状况。如图:

首先是修改密码的页面:

点击确认以后,跳转到登录页面:

但是在登录页面闪一下又回到了修改密码的页面:

刚开始我很崩溃呀,后来在网上搜,也没有什么效果,自己捣鼓了一会儿,把代码改了一下就OK了,修改的代码是:

// 销毁该控制器

[self dismissViewControllerAnimated:YES completion:nil];

// 返回登陆首页

loginViewController *login = [[loginViewController alloc]init];

UIWindow *window = [[UIApplication sharedApplication].windows objectAtIndex:0];

window.rootViewController = login;

时间: 2024-08-05 18:14:07

iOS 跳转出现attempt to dismiss modal view controller whose view does not currently ……的解决方案的相关文章

iOS开发报错之attempt to dismiss modal view controller whose view does not currently appear

刚才遇到一个问题,现在在这就当纪录一下,大家有遇到的能快速找到原因,分享一下啊. 在APP中,需要用户登录后才能使用,所以我通过更改APP的[UIApplicationsharedApplication].keyWindow.rootViewController来控制界面的跳转. 在使用过程中出现如下问题: 1.登录成功后点击注销按钮,弹出注销提示框UIAlertView: 2.注销成功后重新登录: 3.再次点击注销不再弹出UIAlertView. 提示如下警告: 点击注销按钮执行更改rootv

【IOS笔记】View Controller Basics

View Controller Basics   视图控制器基础 Apps running on iOS–based devices have a limited amount of screen space for displaying content and therefore must be creative in how they present information to the user. Apps that have lots of information to display

M2在奋斗之ios开发--View Controller pragramming guide for IOS中文版

About View Controllers 视图控制器是应用程序数据和其视觉外形之间的一个至关重要的链接.无论何时,应用程序显示一个用户界面,其显示的内容都是由一个或一组互相合作的视图控制器管理.因此,视图控制器给你建立的应用程序提供了骨架. iOS提供了很多内置的视图控制器类来支持标准用户界面块(piece),比如导航和标签栏.作为开发应用程序的一部分,你还可以实现一个或多个自定义控制器来显示应用程序的特定内容. 概述 在模型-视图-控制器(MVC)设计模式里,视图控制器是传统的控制器对象,

iOS开发 - View Controller 的paging

在学习开源中国ios 源码时,发现其实现view controllers 的paging的方法如下: 第一.定义一个容器类的view controller,类似于UIPageViewController. 该vc的主要由两部分组成: a 一个title view,用来表明当前内容是什么,并且能够相应用户的点击,切换content b 一个table view controller (通过addChildViewController添加,并将table view controller 的view

iPad keyboard will not dismiss if modal view controller presentation style is UIModalPresentationFor

在ipad上present 一个 navigation controller 时,present后弹出的keyboard,不能够 dismiss 掉.即使 textfield resignFirstResponder,keyboard也不会消失. Problem: 在iPad keyboard上发现一个问题,当viewController在navigation controller下以模态视图弹出,并且navigationController.modalPresentationStyle = U

iOS 两种方法实现左右滑动出现侧边菜单栏 slide view

现在很多的APP中都有slide view,左右滑动出现侧边菜单栏的功能,Weico这个应用就有. 网上有很多第三方的类库实现了这种效果,其实自己代码写的话也是很简单的,下面我将介绍两种方法实现slide view.---- 一种是用第三方类库IIViewDeckController这个类库实现的效果比起其他的都好,另一种是自己代码实现这种效果,效果还ok. 实现方法一(使用第三方库IIViewDeckController): https://github.com/Inferis/ViewDec

Application tried to present a nil modal view controller on target “Current View Controller”解决方案

情景再现 1,自定义一个storyboard: 打开xcode,按下cmd+N,新建一个Storyboard--->next 将新建立的storyboard命名为:TestViewController--->create 在TestViewController.storyboard上加上一个label,其text为:Hello-ios 2,编写UIButton的UIControlEventTouchUpinside事件: - (IBAction)btnClick:(id)sender { //

IOS学习之table view controller、table view cell

A table view controller, like many objects, has more than one init method. There is: • initWithCoder, for view controllers that are automatically loaded from a storyboard • initWithNibName, for view controllers that you manually want to load from a n

Swift - iOS中各种视图控制器(View Controller)的介绍

在iOS中,不同的视图控制器负责不同的功能,采用不同的风格向用户呈现信息.下面对各个视图控制器做个总结: 1,标准视图控制器 - View Controller 这个控制器只是用来呈现内容.通常会用来作为子类,以向屏幕中添加逻辑. 2,导航控制器 - Navigation Controller 这个控制器呈现一个视图控制器的栈,应用程序可以在上面推入更多的视图控制器. 当新视图推入栈,或旧视图弹出栈时,导航控制器会以动画的形式(比如卷动)显示隐藏这些视图. 使用样例:系统“设置”应用程序 3,表