【问题标题】:Integrate with Chartboost objective-c与 Chartboost Objective-c 集成
【发布时间】:2015-12-14 19:33:15
【问题描述】:

我已成功集成 Chartboost 奖励视频,它可以正常工作,但我想实现代码,以便在用户完全观看奖励视频时增加积分。我试图在应用程序委托中实现它并且它可以调用它但是由于一些内部功能我需要在特定的视图控制器中实现。所以当我输入相同的代码时

 -(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 中实现此代码,则不会出现警报视图。我假设它没有在视图控制器中调用,因为它没有响应。我需要帮助在视图控制器中实现

【问题讨论】:

  • 使用 uialertcontroller 代替 uialertview。您需要显示您调用上述方法的代码

标签: ios objective-c chartboost


【解决方案1】:

为了进行 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];
}

【讨论】:

  • 但我的问题是如何确保调用 void。
  • 我没明白你的意思。是否要确保调用并返回此方法 (didCompleteRewardedVideo)?
猜你喜欢
  • 2017-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多