2015-12-14 65 views
1

我已经成功集成了Chartboost奖励视频,它可以工作,但我希望实现在用户完全观看奖励视频时将增加积分的代码。我试图在应用程序委托中实现,它调用它,但由于一些内部函数,我需要在特定的视图控制器中实现。所以,当我把相同的代码与Chartboost集成objective-c

-(void)didCompleteRewardedVideo:(CBLocation)location 
        withReward:(int)reward { 

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"hi ?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; 
    // optional - add more buttons: 
    [alert addButtonWithTitle:@"Yes"]; 
    [alert show]; 


} 

如果我实现特定视图控制器代替的appdelegate这个代码警报视图将不会出现。我认为它没有在视图控制器中调用,因为它没有响应。我需要帮助来实现视图控制器

+0

使用uialertcontroller而不是uialertview。你需要显示你在哪里调用上述方法 –

回答

0

为了进行UI更改,您应该在主队列中调用它。

dispatch_async(dispatch_get_main_queue(), ^{ 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"hi ?" delegate:self  cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; 
// optional - add more buttons: 
      [alert addButtonWithTitle:@"Yes"]; 
      [alert show]; 

     }); 

或者您可以传递视图的代表并在其上显示警报。

-(void) DisplayMessage:(NSString*)message withDelegate:(id)delegate 
{ 
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Title" 
               message:message delegate:delegate 
            cancelButtonTitle:nil 
            otherButtonTitles:@"Ok", nil]; 
[alert show]; 
} 
+0

的代码,但我的问题是如何确保调用void。 – katie

+0

我没有明白你的意思。你想确保这个方法(didCompleteRewardedVideo)被调用并返回? – ozgur

+0

对不起误会 – katie