iPhone - Auto resizing UIWebView content do not fit the frame

后端 未结 8 760
太阳男子
太阳男子 2020-12-23 17:19

I\'m generating an UIWebView into my viewDidLoad method, with a tiny size (let\'s say something like 50x70). And then I put it into a super UIView.

I\'d like to ma

8条回答
  •  时光说笑
    2020-12-23 17:38

    You can do the following:

    oneview.contentMode = UIViewContentModeScaleAspectFit;
    

    That will make the content of your view grow as your view grows. The content will grow as big as possible while still fitting within the UIWebView and without distortion.

    There are other options for this property, and you will find a pretty good explanation of the more complicated ones, along with pictures showing the effect of each, in the View Programming Guide for iOS

    Note that the autoresizing mask you set will make the view itself grow only when its superview grows. If self.view is already big when the small UIWebView is created and self.view does not grow, the UIWebView won't be growing. You're probably aware of this, but I'm adding it just in case, since we can't see self.view's frame in this snippet of code.

    Hope this is helpful.

提交回复
热议问题