在 UIViewController 上基于 NSTimer 更新 UIImage View 和 UITextView。在显示 iAd 的同一个 UIViewController 和 iAd 的正下方有 UIToolbar。当点击 iAd 然后关闭它时,UIViewController 上的 UIToolbar 消失。有谁知道是什么原因?
- (void)viewDidLoad
{
[super viewDidLoad];
float _gap = 1;
myTimer = [NSTimer scheduledTimerWithTimeInterval:_gap
target:self
selector:@selector(onTimer)
userInfo:nil
repeats:NO];
_adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 380, 320, 25)];
_adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
_adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
_adView.delegate=self;
self.bannerIsVisible=YES;
[self.view addSubview:_adView];
}
-(void) onTimer {
if (index < [textArray count])
{
self.textView.text = [self.textArray objectAtIndex:index];
self.imageView.image = [self.imagesArray objectAtIndex:index];
index++;
thisTimer = [NSTimer scheduledTimerWithTimeInterval:1.70 target:self selector:@selector(ViewTiming) userInfo:nil repeats:NO];
}else{
// index = 0;
ViewController *viewController = [[ViewController alloc] init];
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:viewController animated:YES completion:NULL];
}}
-(void)ViewTiming{
if (index == 1) {
self.textView.text = [self.textArray objectAtIndex:index];
self.imageView.image = [self.imagesArray objectAtIndex:index];
index++;
aTimer = [NSTimer scheduledTimerWithTimeInterval:2.55 target:self selector:@selector(Second) userInfo:nil repeats:NO];
}}
-(void)Second{
if (index == 2){
self.textView.text = [self.textArray objectAtIndex:index];
self.imageView.image = [self.imagesArray objectAtIndex:index];
index++;
aTimer = [NSTimer scheduledTimerWithTimeInterval:2.80 target:self selector:@selector(Third) userInfo:nil repeats:NO];
}}
-(void)Third{
if (index == 3){
self.textView.text = [self.textArray objectAtIndex:index];
self.imageView.image = [self.imagesArray objectAtIndex:index];
index++;
aTimer = [NSTimer scheduledTimerWithTimeInterval:2.95 target:self selector:@selector(Fourth) userInfo:nil repeats:NO];
}}
-(void)Fourth{
if (index == 4){
self.textView.text = [self.textArray objectAtIndex:index];
self.imageView.image = [self.imagesArray objectAtIndex:index];
index++;
aTimer = [NSTimer scheduledTimerWithTimeInterval:3.00 target:self selector:@selector(Fifth) userInfo:nil repeats:NO];
}}
-(void)Fifth{
if (index == 5){
self.textView.text = [self.textArray objectAtIndex:index];
self.imageView.image = [self.imagesArray objectAtIndex:index];
index++;
aTimer = [NSTimer scheduledTimerWithTimeInterval:3.00 target:self selector:@selector(Sixth) userInfo:nil repeats:NO];
}}
感谢帮助。