This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set up your tableview/collection view in IB with a bottom layout constraint with an IBOutlet. | |
- (void)viewWillAppear:(BOOL)animated { | |
[super viewWillAppear:animated]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(adjustTableViewHeight:) | |
name:UIKeyboardDidShowNotification | |
object:nil]; | |
} | |
- (void)adjustTableViewHeight:(NSNotification*)notification { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In UICollectionViewCell subclass implementation | |
- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes { | |
layoutAttributes.size = CGSizeMake(layoutAttributes.frame.size.width, layoutAttributes.frame.size.height); | |
return layoutAttributes; | |
} | |
//In your view controller (containing the UICollectionView). | |
//In @interface | |
@property (nonatomic, strong) UICollectionViewFlowLayout *layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In your UIViewController (containing the UICollectionView). | |
//In @interface | |
@property (nonatomic, strong) MyCollectionViewCellSubclass *prototypeCell; | |
//In viewDidLoad | |
//Register your subclassed cell, and load your prototype cell. | |
UINib *cellNib = [UINib nibWithNibName:@"MyCollectionViewCellSubclass" bundle:nil]; | |
[collectionView registerNib:cellNib forCellWithReuseIdentifier:@"MyCollectionViewCellSubclassID"]; | |
self.prototypeCell = [cellNib instantiateWithOwner:nil options:nil][0]; | |