开发者

My view is not refreshing on iPhone

I have an option to disable ads in my app. When that option is enabled, ads should disappear. Now, the ads do in fact disappear when you leave a page that had ads on it and come back to it. But for one page, my MainMenuViewController, for some reason that page does not refresh and the ads stay. For the other pages where it does, when the ads are there, and when I leave that page and come back, the ad itself refreshes and displays a new ad, but for the main menu, it's always the same ad, so it's not refreshing. I have the same code in all my view controller, so I'm not sure why this one is causing trouble. Here are the important methods in the MainMenuViewController:

- (void)viewDidLoad {
    [super viewDidLoad];
    appDelegate = (TestAppDelegate*)[[UIApplication sharedApplication] delegate];
    if(appDelegate.isPremium==NO) {
        self.adView = [[[MobclixAdViewiPhone_320x50 alloc] initWithFrame:CGRectMake(0.0f, 430.0f, 320.0f, 50.0f)] autorelease];
        [self.view addSubview:self.adView];
    }
}
-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.adView resumeAdAutoRefresh];
}

-(void)viewWillDisappear:(BOOL)animated { 开发者_开发百科
    [super viewWillDisappear:animated];
    [self.adView pauseAdAutoRefresh];
}

-(void) viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];
}


- (void)viewDidUnload {
    [super viewDidUnload];
    [self.adView cancelAd];
    self.adView.delegate = nil; 
    self.adView = nil;
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

 - (void)dealloc {
        [super dealloc];
        [self.adView cancelAd];
        self.adView.delegate = nil; 
        self.adView = nil;
    }


If it just happens on that particular view, its probably because its being kept in memory and not being redrawn when you return to it. This is common especially if you are using a navigation controller to manage view controllers in a stack (root view controllers, for example, are always in the stack and tend to stay in memory until that memory is needed otherwise).

Why don't you force the view controller's view to be redrawn with setNeedsDisplay?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜