gpt4 book ai didi

ios - 声明选择器 presentviewcontroller

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:50:29 26 4
gpt4 key购买 nike

你好,我有一个小问题。

我得到了一个项目的应用程序,但它是一个有点旧的应用程序 (IOS 7)。

我在互联网上看到如何使用旧的 UIAlertView 的 INSTEAD 更新 UIAlertController。

if (error.code) {
cancelBlock = block;


UIAlertController *alert = [UIAlertController alertControllerWithTitle: @"Message"
message: @"Peripheral Disconnected with Error"
preferredStyle: UIAlertControllerStyleAlert];

UIAlertAction *alertAction = [UIAlertAction actionWithTitle: @"OK"
style: UIAlertActionStyleDestructive
handler: ^(UIAlertAction *action) {
NSLog(@"OK");
}];

[alert addAction: alertAction];

[self presentViewController: controller animated: YES completion: nil];







/* UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Peripheral Disconnected with Error"
message:error.description
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];*/

我收到一个我不明白的错误:

'RFduino' 的可见@interface 声明了选择器'presentViewController: animated: completion'

最佳答案

而不是使用这个:

[self presentViewController: controller animated: YES completion: nil];

试试这个:

UIViewController *viewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
if ( viewController.presentedViewController && !viewController.presentedViewController.isBeingDismissed ) {
viewController = viewController.presentedViewController;
}

NSLayoutConstraint *constraint = [NSLayoutConstraint
constraintWithItem:alert.view
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationLessThanOrEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1
constant:viewController.view.frame.size.height*2.0f];

[alert.view addConstraint:constraint];
[viewController presentViewController:alert animated:YES completion:^{}];

关于ios - 声明选择器 presentviewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35794964/

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