开发者

UIImageView ignores changes in contentMode

开发者 https://www.devze.com 2023-03-10 09:57 出处:网络
I\'m absolutely stumped with this sizing bug I have.I have a UIImageView and a UITableView in my view layout.The UIImageView is set to Aspect Fit in IB, and it behaves as I want it to when i set the i

I'm absolutely stumped with this sizing bug I have. I have a UIImageView and a UITableView in my view layout. The UIImageView is set to Aspect Fit in IB, and it behaves as I want it to when i set the image using IB. but when I set the image programmatically, it resizes the view incorrectly.

I've tried everything I can think of to get this to appear correctly in the simulator and nothing comes out right.

bannerView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
bannerView.contentMode = UIViewContentModeScaleAspectFit;
bannerView.image = banner;
bannerView.frame = CGRectMake(0,0,320,80);
bannerView.contentMode = UIViewContentModeScaleAspectFit;
self.开发者_JAVA百科tableView.frame = CGRectMake(0,80,320,380);

Now the really interesting thing is that even though by the way I am constructing their frames, the tableview in this code should be directly below the image view. In reality, it is not. The table view doesnt move from where I had placed it in IB (with that exact frame size and coordinates), but the image view is way smaller for some reason.

Pleas help, this doesn't make any sense to me why this doesn't work


Ok, it seems the problem was in IB I had in the autosizing section for the view, all of the arrows were checked, when I only needed the top and left ones checked to keep it aligned

0

精彩评论

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

关注公众号