gpt4 book ai didi

ios - 当前 View Controller 不适用于 ios 9

转载 作者:可可西里 更新时间:2023-11-01 05:03:08 24 4
gpt4 key购买 nike

当前 View Controller 不适用于 ios 9,当我按下按钮时,它不会重定向到当前 View Controller 。

为什么会这样?

I had tried the below code

 RegistrationViewController * viewController =[[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
[self presentViewController:viewController animated:YES completion:nil];

I had also tried the below code

 UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Registration"
bundle:nil];
RegistrationViewController *add =
[storyboard instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
[self presentViewController:add animated:YES completion:^{
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:add
animated:YES
completion:nil];
});
}];

编辑

My complete code here. I am using Xcode 7 and running it with ios 9

#import "LoginViewController.h"
#import "RegistrationViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


- (IBAction)actionRegistrationClicked:(id)sender
{
RegistrationViewController * viewController =[[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];
[self presentViewController:viewController animated:YES completion:nil];

}
@end

Registration view controller

#import "RegistrationViewController.h"

@interface RegistrationViewController ()

@end

@implementation RegistrationViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

最佳答案

确保 presentedViewController 为 nil。如果 presentedViewController 不是 nil,则将代码更改为以下内容。

RegistrationViewController * viewController =[[UIStoryboard storyboardWithName:@"Registration" bundle:nil] instantiateViewControllerWithIdentifier:@"RegistrationViewController"];

if ([self presentedViewController]) {
[[self presentedViewController] dismissViewControllerAnimated:NO completion:^{
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:viewController animated:YES completion:nil];
});
}];
} else {
[self presentViewController:viewController animated:YES completion:nil];

}

关于ios - 当前 View Controller 不适用于 ios 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33758859/

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