Reputation: 243
I get one problem is that,
This's showads
function.
[self.mMainView addSubview:adViewController.view];
//...(my function to display ads)
This's hideads
function.
//...(my function to hide ads)
[[AdViewController sharedAdViewController].view removeFromSuperview];
[self.mMainView setNeedsDisplay];
The mMainView
is a UIView
.
The AdViewController
is a UIViewController
.
The problems is that after calling showads
fucntion, the my ads display on mMainView
. But after calling hideads
function, the my ads don't disappear, it still appear on mMainView
.
Note: After calling hideads
and make an interrupt then resume the app, the my ads will disappear.
So, i want to remove it, could you please explain a bit in more detail and show me how to fix it if you can pls ?
Upvotes: 2
Views: 3154
Reputation: 1853
You don't need to call setNeedsDisplay
when removing or adding subviews. The fact that it updates after an interrupt makes me suspect that you're not calling [[AdViewController sharedAdViewController].view removeFromSuperview];
on the main thread. What is the context of that code?
If it's not on the main thread, you can schedule on it:
dispatch_async(dispatch_get_main_queue(), ^{
[[AdViewController sharedAdViewController].view removeFromSuperview];
});
Upvotes: 2