I know there is a message: adding a contentView via nib to the UICollectionViewCell , asking about it, but the answer is incorrect. By dragging a UILabel directly into the xib cell, the label will be added to the cell, not to the contentView:
(lldb) po self.subviews <__NSArrayM 0x7fa9b1c58a20>( <UIView: 0x7fa9b1c77540; frame = (0 0; 64 64); gestureRecognizers = <NSArray: 0x7fa9b1c66260>; layer = <CALayer: 0x7fa9b1c352f0>>, <UILabel: 0x7fa9b1c7a880; frame = (0 15; 64 18); text = 'market share'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fa9b1c6f820>>, <UILabel: 0x7fa9b1c77c30; frame = (0 38; 64 22); text = '17.06'; opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7fa9b1c36fe0>> ) (lldb) po self.contentView.subviews <__NSArray0 0x7fa9b1d02740>( )
This is still true for Xcode 7, sample: https://github.com/liuxuan30/autolayoutProblemOniOS9 .
So I asked him again for a good answer.
The behavior is different from UITableViewCell, which will directly display the contentView in xib. I don't know why Apple did this and said in the UICollectionViewCell doc https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionViewCell_class/ :
, , contentView. .
, Apple, , cellView, xib, , , sub.contentView subView.
, sub- xib, contentView, xib UICollectionViewCell xib. ContentView xib, UITableViewCell.
Source: https://habr.com/ru/post/1623190/More articles:Apache - AH00341: winnt_accept: asynchronous AcceptEx failed - ssl"SourceError Unknown source plugin" when I try to convert js files to a directory using babel cli - javascriptHow can I access the angular2 Http service before calling bootstrap ()? - dependency-injectionUsing polymorphism? - javaFailed to import cv2 into python2.7 on OSX El Capitan (opencv3.1.0) - pythonGitlab CI with MATLAB - unit-testingNavigation menu items like Google Play Store - androidadding to UICollectionViewCell contentView via nib - iosPattern matching (any, any) as (string, string) does not work in case of a switch - string(Windows Phone 10) Можно ли редактировать, добавлять новые контакты программно в Windows Phone 10? - windowsAll Articles