gpt4 book ai didi

IOS 我得到了 [UIWindow Controller transition :fromViewController:toViewController:target:didEndSelector:] error

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:18:52 25 4
gpt4 key购买 nike

错误不是每次都有。我曾尝试清理和重建应用程序,但它也是。

错误:

 *** Assertion failure in -[UIWindowController 
transition:fromViewController:toViewController:target:didEndSelector:],
/SourceCache/UIKit_Sim/UIKit-2372/UIWindowController.m:211

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Attempting to begin a modal transition from
<UINavigationController: 0x9190730> to <UINavigationController: 0x83a9dc0>
while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear
to know the current transition has completed'

*** First throw call stack:
(0x213d012 0x1e85e7e 0x213ce78 0x191bf35 0x10b8d05 0xeb74f3 0xeb7777 0x10be033f
0xeb77b7 0x104f0 0x1e996b0 0x18c6035 0x20c0f3f 0x20c096f 0x20e3734 0x20e2f44
0x20e2e1b 0x36437e3 0x3643668 0xdcd65c 0x1133f2 0x25c5)
libc++abi.dylib: terminate called throwing an exception

基础 Controller .h:

 @class LoginViewController;
@interface BaseController:UIViewController
//...
@end

BaseController.m

 @implement BaseController
//...
-(void)showLoginForm
{
UIViewController* loginx =(UIViewController*) [[LoginViewController alloc] init];
UINavigationController* navx = [[UINavigationController alloc] initWithRootViewController:loginx];
[navx.navigationBar setBackgroundImage:[UIImage imageNamed:@"title_bar.png"] forBarMetrics:UIBarMetricsDefault];
//added
//i can use @try to catch it
[self presentModalViewController:navx animated:YES];//<====it is error

[loginx release];
[navx release];
}

登录 View Controller :

 @interface LoginViewController:BaseController
//...
@end

其他 View Controller :我将在这个 Controller 中判断用户是否登录。如果不是登录,我将调用 showLoginForm

  //@interface otherViewController:BaseController
//......
-(void)viewDidLoad
{
//make a thread to call isLogin
}
-(void)isLogin
{
BOOL logined = YES;
//......
if(!logined)//i take this on MainThread,it has error also.
[super showLoginForm];
}

MainViewController:(显示其他ViewController的是Main ViewController)

 //@interface MainViewController:BaseController
//......

-(void)buttonAction
{
otherViewController* other = [[otherViewController alloc] init];
UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:other];
[self presentModalViewController:navigation animated:YES];
//release
}

所以,谁知道这是怎么回事?

最佳答案

在otherViewController.m中你应该将调用isLogin方法的代码移到

- (void)viewDidAppear:(BOOL)animated

这将确保当 [self presentModalViewController:navx animated:YES]; 被调用时,otherViewController 的呈现转换将完成。

关于IOS 我得到了 [UIWindow Controller transition :fromViewController:toViewController:target:didEndSelector:] error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13321203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com