声明选择器 presentviewcontroller
declares the selector presentviewcontroller
你好,我有个小问题。
我收到了一个项目的申请,但它是一个有点旧的申请 (IOS 7)。
我在 Internet 上看到了如何使用旧的 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'
presentViewController: animated: completion:
是UIViewController
的一个方法。您调用此方法的 class 是 UIViewController
的子 class 吗?
而不是使用这个:
[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 7)。
我在 Internet 上看到了如何使用旧的 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'
presentViewController: animated: completion:
是UIViewController
的一个方法。您调用此方法的 class 是 UIViewController
的子 class 吗?
而不是使用这个:
[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:^{}];