Hello I have a little problem.
I got an application for a project, but it is a somewhat old application (IOS 7).
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:
No visible @interface for 'RFduino' declared the selector 'presentViewController: animated: completion'
Instead of using this:
[self presentViewController: controller animated: YES completion: nil];
Try this:
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:^{}];