2016-03-04 74 views
1

你好,我有一個小問題。聲明選擇器presentviewcontroller

我得到了一個項目的應用程序,但它是一個有點舊的應用程序(IOS 7)。

我在網上看到如何更新UIAlertController使用舊版UIAlertView的INSTEAD。

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:動畫:完成'

+0

是什麼RFduino您在項目 – techloverr

回答

5

而不是使用這個的:

[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:^{}]; 
+0

我有一個問題,我已經發布,但我沒有得到任何答案所以你能幫我解決這個問題。 問題鏈接是: - [http://stackoverflow.com/questions/35769368/gpuimage-video-filter-set-brightness-not-working] – DJ1

+0

@ Dh1_Bh1 - 對不起兄弟我沒有在這種情況下工作 –

+0

好吧。謝謝。我會管理它。 – DJ1

1

presentViewController: animated: completion:UIViewController的方法。您調用此方法的類是UIViewController的子類?