我要求在一个amy应用程序中显示iAds,但问题是它会在一段时间后显示10或15秒,即使间隔时间不固定。 我没有得到这个的头或尾。有可能以编程方式吗?即使有可能它会被苹果批准吗? 感谢您的帮助。
答案 0 :(得分:1)
浏览iAd Programming Guide我找不到任何明确指示,不按照您的建议定期隐藏和显示iAd。
要实现这一目标,最好的方法是使用NSTimer。
我会声明一个属性:
/** A timer used to time how long an iAd should show. */
@property (nonatomic, strong) NSTimer *iAdTimer;
然后我会创建一个启动计时器并显示iAd的方法:
/**
* Displays the iAd banner and starts a timer to hide it again.
*/
- (void)displayiAdBanner
{
NSDate *fireDate = [[NSDate alloc] initWithTimeIntervalSinceNow:15.0f];
self.iAdTimer = [[NSTimer alloc] initWithFireDate:fireDate interval:0.0f target:self selector:@selector(hideiAdBanner) userInfo:nil repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:self.iAdTimer forMode:NSRunLoopCommonModes];
// show the banner here in whatever way you are currently doing it...
}
然后显然你需要隐藏横幅的方法:
/**
* Hides the banner and stops the timer.
*/
- (void)hideiAdBanner
{
[self.iAdTimer invalidate];
self.iAdTimer = nil;
// hide the banner here
}