layoutsubviews

How I can round UIImageView in UICollectionViewCell?

爷,独闯天下 提交于 2019-12-07 17:24:46
问题 In my UICollectionViewCell class I wrote this: - (void)layoutSubviews { [super layoutSubviews]; self.myImageView.layer.cornerRadius = CGRectGetHeight(self.myImageView.frame) / 2; self.myImageView.layer.masksToBounds = YES; } But this does not work correctly in all cases, it appears like this: 回答1: I faced a similar problem trying to get a collectionView inside a TableView Cell. If you are changing your cell's model you should tell the cell to recalculate its layout so the cell changes its

layoutsubviews only called once despite any device rotation

梦想的初衷 提交于 2019-12-06 10:17:13
问题 just what the title says: I create an empty UIView subclass and I add a subview to it, I create an empty layoutSubviews method and I add a breakpoint there. Then I build the project and the simulation stops when loading the view at that point in the layoutSubviews method. Everything is fine so far. I continue the simulation and I rotate the device (assuming that the view controller is set to allow any orientation) but layoutSubviews is never called again, despite I can see how my object is

How I can round UIImageView in UICollectionViewCell?

为君一笑 提交于 2019-12-05 19:06:21
In my UICollectionViewCell class I wrote this: - (void)layoutSubviews { [super layoutSubviews]; self.myImageView.layer.cornerRadius = CGRectGetHeight(self.myImageView.frame) / 2; self.myImageView.layer.masksToBounds = YES; } But this does not work correctly in all cases, it appears like this: Pablo Romeu I faced a similar problem trying to get a collectionView inside a TableView Cell . If you are changing your cell's model you should tell the cell to recalculate its layout so the cell changes its size and calls layoutIfNeeded . - (UICollectionViewCell *)collectionView:(UICollectionView *

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

家住魔仙堡 提交于 2019-12-04 18:32:36
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. The idea is to create the custom view (which is a row of items) and then when the UITableViewCell hits layoutSubviews it will (a) set itself up re positioning and (b) loop through and call "layoutSubviews" on each of the rows of the custom UIViews it is using for the rows. Question - I'm not sure how to correctly set the size/position of the custom

layoutsubviews only called once despite any device rotation

人走茶凉 提交于 2019-12-04 17:36:19
just what the title says: I create an empty UIView subclass and I add a subview to it, I create an empty layoutSubviews method and I add a breakpoint there. Then I build the project and the simulation stops when loading the view at that point in the layoutSubviews method. Everything is fine so far. I continue the simulation and I rotate the device (assuming that the view controller is set to allow any orientation) but layoutSubviews is never called again, despite I can see how my object is rotating. Any idea? OK, i will simplify my question: How do I create a custom UIView with some subviews

where to create autolayout constraints for subclassed uitableviewcell?

早过忘川 提交于 2019-12-03 03:53:13
问题 I am trying to use autolayout for a uitableviewcell subclass I am creating and I would appreciate some advice on what method to put the layout constraint creation code. I have been searching around and all the information I find talks about adding constraints after adding subviews in the viewDidLoad method. As far as I know viewDidLoad isn't an option for a uitableviewcell subclass. I am using interface builder to create a custom cell and dynamically allocating it in my code. Nothing special

UITableView: How to change cell height dynamically when a button is clicked in it?

对着背影说爱祢 提交于 2019-11-30 16:06:52
问题 I have a UITableView, in which each cell has a button. When the button is clicked, the cell's height will be changed. Of course, the whole tableview height will be changed according to it. I cannot find a way during long surfing. What is an elegant solution to achieve this? 回答1: (See this answer. Kudos to Tapas Pal for writing the original answer. I just changed it to better fit your question.) You will need a BOOL variable to tell the cell that its height should be different from the others.

UITableView: How to change cell height dynamically when a button is clicked in it?

我只是一个虾纸丫 提交于 2019-11-30 15:46:28
I have a UITableView, in which each cell has a button. When the button is clicked, the cell's height will be changed. Of course, the whole tableview height will be changed according to it. I cannot find a way during long surfing. What is an elegant solution to achieve this? Bruno Ely (See this answer. Kudos to Tapas Pal for writing the original answer. I just changed it to better fit your question.) You will need a BOOL variable to tell the cell that its height should be different from the others. You will also need a number (here, I will use NSInteger ) variable so that you can increase the

Xcode6, iOS8 and (void)layoutSubviews

柔情痞子 提交于 2019-11-29 06:58:53
I have custom UILabel which works fine on iOS6 and iOS7. But on iOS8 this label's (void)layoutSubviews method never get called. I create this label with initWithFrame, so this method should be called - and it's called on another iOS versions. What happens with autoLayout system in iOS8? I just want to add this answer because the question title may lead a lot of ppl here with similar issues (like me). With iOS 8 to 8.0.2 LayoutSubviews calls are unreliable. They may not be called ever or (in my case) are called in a loop. Even though you should not do it, it was pretty safe to alloc stuff in

UIView/CALayer: Transform triggers layoutSubviews in superview

谁说我不能喝 提交于 2019-11-28 06:48:59
When changing some of the properties for UIView it triggers layoutSubviews in the superview . I can not find any statements about this in the docs. These properties triggers layout in superview and self frame bounds These properties triggers layout in superview only transform layer.transform These properties triggers layout in self only none These properties does not trigger any layout center layer.anchorPoint layer.position alpha I find it very confusing that transform is triggering layout and that position and anchorPoint does not. Example code : https://github.com/hfossli