Reputation: 2942
I have an UICollectionView and a custom UICollectionViewCell containing subviews. I am doing some "esoteric" stuff inside this CollectionViewCell and would like do rearrange all subviews by using setFrame manually. How can I override all autolayout behaviour?
I tried to override "-(void) layoutSubviews" and draw rect. Sometimes this works, sometimes not.
If I get a cell by using
UIMyCell *cell = (UIMyCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"UIMyCell" forIndexPath:indexPath];
I get my custom cell. I can assign custom properties and everything is fine. But the frame of this cell is initially (0, 0, 0, 0).
Some time later the layout will be set. I would like to be "notified" if the subsystem is setting the size.
Then I would like to set all subviews frames WITHOUT autolayout.
What is the best practice here?
Upvotes: 1
Views: 797
Reputation: 2942
Finally I found the answer. On OS X (NSView)
-(void) setFrame:(CGRect)frame
will be called after all constraints have been updated to set new view positions and sizes. On iOS (UIView)
-(void) setCenter:(CGPoint)center
and
-(void)setBounds:(CGRect)bounds
will be called instead. So overwriting setFrame is not working for iOS framework.
Upvotes: 2