Questions tagged [sizetofit]

- sizeToFit Resizes and moves the receiver view so it just encloses its subviews.

Declaration in OBJECTIVE-C

- (void)sizeToFit

Declaration in SWIFT

func sizeToFit()

Discussion Call this method when you want to resize the current view so that it uses the most appropriate amount of space. Specific UIKit views resize themselves according to their own internal needs. In some cases, if a view does not have a superview, it may size itself to the screen bounds. Thus, if you want a given view to size itself to its parent view, you should add it to the parent view before calling this method.

You should not override this method. If you want to change the default sizing information for your view, override the sizeThatFits: instead. That method performs any needed calculations and returns them to this method, which then makes the change.

Availability Available in iOS 2.0 and later.

95 questions
0
votes
2 answers

UILabel Dynamic Content auto size trouble

Please, I need some help with some UILabels that must hold dynamic content. They are contained in a UIScrollView. I can't get them to resize properly depending on screen orientation. I also want to keep an exact distance between them. Right now,…
Razvan
  • 3,972
  • 2
  • 22
  • 43
0
votes
1 answer

UIImageView overflowing its containing UIView after calling sizeToFit

My UIView (width: 352px) has a UIImageView subview (default width in Storyboard: 312px). I want the UIImageView to adapt itself to the dimensions of the image it contains with the constraint that the width of the image view shouldn't exceed a…
Dirty Henry
  • 6,978
  • 6
  • 48
  • 92
0
votes
1 answer

IOS UILabel sizeToFit

I want to use the sizeToFit method to display a variable amount of text in a UILabel. It works perfectly to show all the text...but is there a way to use sizeToFit up to a certain maximum frame height. In other words, I want to have sizeToFit…
user1467188
  • 607
  • 1
  • 9
  • 28
0
votes
1 answer

objective c: fit twitter page width in UIWebview

I have a UIWebview in which a twitter page loads. Because twitter is being opened from a mobile device it opens the mobile twitter which has a specific width depending on device, and device orientation. Now my query: my UIWebview's width is shorter…
pnizzle
  • 5,359
  • 3
  • 38
  • 70
-1
votes
1 answer

how to fix width in UIButton's sizeToFit/sizeThatFit?

I found the sizeToFit or sizeThatFits will change UIButton 's current width. UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(100, 100, 200, 40); btn.backgroundColor = [UIColor redColor]; [btn.titleLabel…
ximmyxiao
  • 2,130
  • 3
  • 17
  • 28
1 2 3 4 5 6
7