声明选择器presentviewcontroller [英] declares the selector presentviewcontroller
本文介绍了声明选择器presentviewcontroller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我有一个小问题。
Hello I have a little problem.
我有一个项目的应用程序,但是它有点旧了(IOS 7)。
I got an application for a project, but it is a somewhat old application (IOS 7).
我在互联网上看到了如何使用旧版UIAlertView的INSTEAD更新UIAlertController。
I saw on the internet how to update the UIAlertController Using INSTEAD of good-old UIAlertView.
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];*/
我收到一个我不理解的错误:
I get an error that I do not understand:
'RFduino'的可见@interface声明选择器'presentViewController:animated:completion'
No visible @interface for 'RFduino' declared the selector '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:^{}];
这篇关于声明选择器presentviewcontroller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文