Questions tagged [layoutsubviews]

layoutSubviews is a method that is called automatically during view size changes. It can be used by a custom view to perform additional manual changes above and beyond any autoresizing behaviours

This method is called automatically and should not be called directly. UIKit will call it automatically whenever a view size changes. This could be as a result of resizing due to orientation changes. For example when the user rotates the iOS device to portrait or landscape mode.

In the custom view that implementslayoutSubviews, any view changes in addition to the autoresizing behaviours should be applied.

For further information please refer to the View Programming Guide for iOS. See the section on "Tweaking the Layout of Your Views Manually".

See also the UIView Class Reference.

149 questions
2
votes
0 answers

MPMoviePlayerController not rotating views when in fullscreen mode

I am currently working on a masterDetail app for iPad iOS 5.1. when a row is tapped in the masterViewController, a video is played in the detail view controller. The video plays fine and can be rotated when in full screen mode. However, when the…
1
vote
1 answer

UIScrollView content size clipping subviews when it shouldn't

I have a UIScrollView that contains several dynamically resizing subviews. I can resize and layout the subviews just fine, but when I set the content size of the scroll view itself, the bottom subviews are clipped. Is there some reason why a scroll…
1
vote
1 answer

Animations inside of layoutSubviews?

I have a view (LSTabBarView) which supports insertion/deletion of new elements with the following methods: - (void)insertItem:(LSTabItem *)item atIndex:(NSUInteger)index animated:(BOOL)animated; - (void)removeItemAtIndex:(NSUInteger)index…
ggould75
  • 880
  • 2
  • 14
  • 23
1
vote
1 answer

When I used layoutSubviews method of UItableViewcell with category in my file,something disappeared

when I used layoutSubviews method of UItableViewcell with category, just like the code below @implementation UITableViewCell (forimage) - (void)layoutSubviews{ [super layoutSubviews]; self.imageView.frame = CGRectMake(0, 0, 50,…
Siverchen
  • 379
  • 2
  • 16
1
vote
0 answers

UIView.snapshotView seems to be synchronous by definition but acts as asynchronous

I need to make the snapshot of my view, to achieve this I'd like to use open func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? UIView function. This function seems to be synchronous since it returns the view not in a closure but…
starwarrior8809
  • 361
  • 1
  • 10
1
vote
2 answers

how do I set the size/position of a custom UIView for its placing within a custom UITableViewCell?

How do I set the size of a subview which is being placed programmatically inside a UITableViewCell? I have a custom (subclassed) UITableViewCell in which part of the cell includes a number of rows (dynamic) which are implemented as a custom UIView. …
Greg
  • 34,042
  • 79
  • 253
  • 454
1
vote
2 answers

How to access UITableViewController variable from within a subclass'ed UITableViewCell?

How do I access UITableViewController parameter from within a subclass'ed UITableViewCell? I have a parameter in the UITableViewController for the font size (i.e. users can change font size). So the layoutSubviews method in my custom subclassed…
Greg
  • 34,042
  • 79
  • 253
  • 454
1
vote
0 answers

Swift 4: didSet @IBOutlet calls viewDidLayoutSubviews, but not with addSubview()

When selectCard is called, by commenting out various parts of the code I've discovered that viewDidLayoutSubviews is only called when score is updated in checkIfCardsMatch function. The score is only updated if we have matchedCards. Why is this…
Turnipdabeets
  • 5,815
  • 8
  • 40
  • 63
1
vote
0 answers

LayoutSubviews() in custom UITableViewCell doesn't work with all reused cells

I try to have a custom edit view and animation for the edit mode of the cells in my UITableView, so I made a custom class, added my subviews to it and animate some frame changes in the setEditing(_:animated:) function. I also override the…
Josef Zoller
  • 921
  • 2
  • 8
  • 24
1
vote
0 answers

How can I get the correct tableView height after resizing my tableViewcell

tl;dr How can I get correct the height of my tableView after cell height changes made due to cell expansion——without using delays? My tableViewcells, expand and collapse. Because of that I need to pass (using a delegate method) the tableView's…
mfaani
  • 33,269
  • 19
  • 164
  • 293
1
vote
0 answers

understanding layoutSubviews different behaviors

I have two group of buttons. They should have rounded rects for different screen sizes. so I wrote: override func layoutSubviews() { submitButton.layer.cornerRadius = updateButton.bounds.size.height / 2 cancelButton.layer.cornerRadius =…
mfaani
  • 33,269
  • 19
  • 164
  • 293
1
vote
2 answers

Using layoutsubviews() works properly when cycling through UIButtons, but not when cycling while retrieving them by tag

I'm trying to mimic the iPhone Springboard drag and drop functionality for a tile game and am currently using MatrixCells to generate UIButtons in the View initalisation and add them to the view. The MatrixCells have an order tag, which is used for…
SpacyRicochet
  • 2,269
  • 2
  • 24
  • 39
1
vote
2 answers

Manual positioning of titleLabel in a custom UIButton (using layoutSubviews)

i've create a UIButton subclass for my app and i need to manually reposition the titleLabel to be about 1/4 of the button's height. this post; http://forums.macrumors.com/showthread.php?t=763140 appears to directly address the same issue, and the…
1
vote
3 answers

How to invoke drawRect: when layoutSubviews invokes in ios

I am using drawRect: to draw shapes. I have to invoke this method and redraw the shapes when orientation changes, so i thought if there is a way to invoke drawRect: automatically when layoutSubviews() been called. Thank you.
Sunil Rao
  • 800
  • 2
  • 6
  • 23
1
vote
1 answer

Fit a Vertical UISlider into an Existing Container View?

I want to create a vertical UISlider and exactly fit it into an existing container view that is sized and placed from a .xib file using autoLayout. But I simply cannot get it to work and I have Googled my fingers bloody. The closest I have gotten…
PaulB
  • 128
  • 8