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
0
votes
1 answer

UIScrollView not calling layoutSubviews while zooming on iOS 4.0

I've read many of the UIScrollView questions asked on here but none of them answered this problem. I have a UIScrollView that zooms a view containing other subviews. When a zoom is happening, I need to have the subviews of the view move to certain…
spybart
  • 2,583
  • 3
  • 22
  • 33
0
votes
1 answer

UIButton align image left and center text

Introduction: I have a class, which inherits from UIButton. In this class I want to update properties, like titleEdgeInsets, imageEdgeInsets, contentHorizontalAlignment. My first approach was to use layoutSubviews: override func layoutSubviews() { …
Sean Stayns
  • 4,082
  • 5
  • 25
  • 35
0
votes
1 answer

Infinity cycle for textView on iOS 10.2

I connected the library - JVFloatLabeledTextField to my project. I started on a real device, but the problem can be reproduced on the simulator (I tried with iphone 7 plus iOS 10.2). If you enter some text in the textView, then select the text and…
0
votes
1 answer

Swift LayoutSubViews Order

I have a view with 2 sub-views - collectionView and a custom view. I want to set an action to run after the 2 views have been laid out, but layouSubViews is running twice and I can't differentiate between the 2 instances, so my action is being…
Ran
  • 277
  • 4
  • 8
0
votes
3 answers

addView(View) not adding objects to the contentView

In the following code, you will see I have created my layouts all programmatically. I have set the contentView and added a view inside of that contentView, which contains 2 buttons. The contentView is being set and working fine, however all…
user8494778
0
votes
2 answers

In new xcode layoutSubviews is not called

I have code that animate a view (change constraints) UIView .animate(withDuration: TimeInterval(duration), delay: 0.0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseInOut, animations: { self.topConstraint!.constant…
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
0
votes
2 answers

How to be notified when a UIView is fully loaded

I have a UIView being added to a UIViewController, I want to ensure the views have been fully loaded as I want to access and use the frames of these views. I am working within the UIView and the ViewController is just for testing purposes. Here is…
sam_smith
  • 6,023
  • 3
  • 43
  • 60
0
votes
1 answer

why do my constraints make the layout different while running app on iphone 5 and iphone 6?

I am designing a swift app that shows a photo, map and content - all of that in UITableView header. When I run the app on iphone 5, it looks like this: The yellow field is a text view that has the following constraints: and: This looks fine on…
user3766930
  • 5,629
  • 10
  • 51
  • 104
0
votes
1 answer

Views not laying out correctly in iOS share extension

I have a NavigationVC which I display both in my app and in a share extension, which includes just a search view and a table view. In my app, it appears correctly, but in my share extension, the search view appears 20 pixels too high, and is…
Andrew
  • 7,693
  • 11
  • 43
  • 81
0
votes
1 answer

UIScrollView - detecting scrolling vs orientation change in layoutSubviews?

Question - In the "layoutSubviews" callback of a custom UIScrollView how could one detect the different of scrolling (which may not require subview re-layout) with other events such as an orientation change (which does require re-layout)? …
Greg
  • 34,042
  • 79
  • 253
  • 454
0
votes
0 answers

Toggle Between Staggered and Linear Layouts (with one menu item)

Main Question [ I want to be able to toggle between menu items Linear View and Staggered View without having two items shown as soon as one is clicked the view should change and the other menu item would show how can i accomplish this (similar to…
0
votes
0 answers

iOS tableview cell layoutSubviews

#import "UITableViewCell+Line.h" @implementation UITableViewCell (Line) - (void)layoutSubviews{ [super layoutSubviews]; for (UIView *subview in self.contentView.superview.subviews) { if ([NSStringFromClass(subview.class)…
0
votes
1 answer

Reordering subviews programatically won't work in a tableViewCell

I'm trying to reorder an image and a stackview (here called labelsStack) that are both contained in another stackview (here called stack). My goald would be to programatically reverse the index order of both subviews in order to change their…
Yann Massard
  • 283
  • 2
  • 16
0
votes
1 answer

iOS 7 issue with autolayout

In the app I support iOS 7+. But I can't download a simulator to test it on iOS 7, because the latest simulator available is iOS 8. Everything works fine on iOS 8 and iOS 9. But my customer has iPhone 4 with iOS 7 and when he runs the app, it…
Paul T.
  • 4,938
  • 7
  • 45
  • 93
0
votes
2 answers

How do I get the real custom cell's width?

I have a custom cell in storyboard. I've set iPhone 4.7 inch in storyboard for the viewController that contains its tableView. Since I want to lay out some UIImageViews in a scrollView that is inside this cell, I need to know the width of the cell.…
Erfan
  • 143
  • 10