Question

I have an iAd which I want to be able to change the placement on the y axis in code. The ad is called on and spawned by this code:

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
    [UIWebView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:1];
    [UIView commitAnimations];
}

I tried to change the position of the ad by doing something like this:

banner.frame.origin.y += 100;

or

banner.frame.origin.y = 100;

But I'm always left with the error: Expression is not assignable

Was it helpful?

Solution

You can't directly assign frame position directly on an UIView. You have to:

CGRect frame = banner.frame;
frame.origin.y += 100; //Or whatever change you want to perform.
banner.frame = frame;

If you feel curious about why this happens, check out this answer here at stackoverflow: https://stackoverflow.com/a/7074522/1152596

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top