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
0 answers

Autolayout layoutSubviews called when changing frames

Here is an analysis of how things work and I wish I could find an explanation for this behaviour without having to read the entire Internet about Auto Layout on iOS6+. I have 3 similar scenarios, depicted in following images. The only difference is…
AndroC
  • 4,758
  • 2
  • 46
  • 69
0
votes
1 answer

iOS 7 UITextView - layoutSubviews infinite loop

I have UITextView: textView = [[UITextView alloc] init]; textView.scrollEnabled = NO; I have a problem only on iOS7: On every keyboard keystroke, layoutSubviews is called on superview. After writing several characters, it gets stuck in infinite…
AndroC
  • 4,758
  • 2
  • 46
  • 69
0
votes
1 answer

Custom UIVIew layoutSubviews causes an error when setting a transform (AutoLayout asks me to call super method even though I already am)

I've got a strange issue where I'm trying to override -layoutSubviews to create a different layout in landscape. My method works fine in portrait, but when I set a transform on one of my subviews in landscape, I get this error: *** Assertion…
Brandon
  • 182
  • 11
0
votes
1 answer

Set UIFont for a UILabel in UITableViewCell subclass

Is it advisable to set UIFont of a UILabel in layoutSubviews. I am subclassing a UITableViewCell. We use layoutSubview to adjust the UIView frame if required, so I am not sure whether I should go with it. Also, is there is method like viewDidLoad,…
weber67
  • 525
  • 1
  • 9
  • 18
0
votes
1 answer

UITableView Visible Cells Not Laying Out Subviews When View Appears

I have a UITableView that has multiple sections, with custom UITableViewCell subclasses populating the table. Within these UITableViewCell subclasses, I am implementing layoutSubviews to customize the position of labels, etc. All of the cell's…
AUSTOOO
  • 41
  • 1
  • 9
0
votes
1 answer

UIScrollview overlapping mainview content

Currently, I have this feature in my app where I implemented a UIScrollview that is pretty thin in height but long in width... As you can see, the UIScrollView is OVERLAPPING the backgroundview... Not that white background is a UIView to which I…
0
votes
1 answer

How to detect which view is touched?

Suppose I have a button that everytime I clicked it will generate a random number of subviews. Is there anyway to detect the subview touched?
Q.u.a.n.g L.
  • 1,564
  • 1
  • 12
  • 27
0
votes
0 answers

Custom UITableViewCell and subviews position

In my custom UITableViewCell i rewrite method (void) layoutSubviews, in this method i set new subviews position: for (NSUInteger i = 0; i < views.count; ++i) { ViewData *viewData = (ViewData *)[views objectAtIndex:i]; CGFloat x_pos = i <=…
0
votes
1 answer

Rearranging subviews from 2 line to 1 according to the device orientation

G’day guys, I am initially targetting the iPhone, with iOS6.1 but hints and code able to run flawlessly also on the iPhone with iOS5.1 is welcome. I have a custom UITableViewCell with 7 different labels as subviews: -(id) initWithStyle:…
nico9T
  • 2,496
  • 2
  • 26
  • 44
0
votes
2 answers

Should we add UITableView in initializer or layoutsubviews method in iOS?

I am designing a Custom UIView for my app. The UIView will comprise of below components: UISearchbar UITableView My initialiser is below: - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { …
RK-
  • 12,099
  • 23
  • 89
  • 155
0
votes
1 answer

Why UIScrollView's scrolling triggers layoutSubViews method in iOS 4.3 but not in 5.0 & above?

I have customized UIView to create a custom UI component. The hierarchy of views are this way. ----Custom UIView ----------------UIScrollView -----------------------------Sub Views in ScrollView -(id)initWithFrame:(CGRect)frame{ self = [super…
RK-
  • 12,099
  • 23
  • 89
  • 155
0
votes
1 answer

Auto position subviews of UINavigationBar's titleView

I have a custom titleView for displaying Navigation title and sub-title. The title font is bigger than sub-title. Here's what I have now: CGRect headerTitleSubtitleFrame = CGRectMake(0, 0, 200, 44); UIView* _headerTitleSubtitleView = [[[UILabel…
AmitP
  • 5,353
  • 4
  • 35
  • 27
-1
votes
1 answer

UIButtons setAttributedTitle Disappears After Calling layoutSubviews in UIButton Extension

I had a corner radius problem with all of my UIButtons, but was finally able to resolve the issue by following the solution at (Setting corner radius through viewDidAppear() or viewWillLayoutSubviews()? ) However, now I have "lost" all of my…
Tony Pendleton
  • 358
  • 1
  • 11
-2
votes
1 answer

In layoutSubviews cell bounds or frame should be set?

I am afraid to set cell's frame in layoutSubviews, because I know I want to place cell into 0 origin.x position, but I am not sure about origin.y position. But sometimes set only the bounds so the size of the cell, has strange effect, i.e. cell…
János
  • 32,867
  • 38
  • 193
  • 353
1 2 3
9
10