मैं UICollectionView
देखा here infinitive स्क्रॉलिंग को फिर से लागू करने की कोशिश कर रहा हूं। चीजें हैं जो मेरे लिए लापता गया:UICollectionView के बजाय एक ब्लैक स्क्रीन प्रदर्शित होती है
ViewController.h:
@interface ViewController : UIViewController<UICollectionViewDataSource, UICollectionViewDelegate>
@end
DataCell.h:
@interface DataCell : UICollectionViewCell
@property (nonatomic, strong) UILabel *label;
@end
DataCell.m:
#import "DataCell.h"
@implementation DataCell
-(instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if(self){
self.label = [[UILabel alloc] initWithFrame:self.bounds];
self.autoresizesSubviews = YES;
self.label.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
self.label.textAlignment = NSTextAlignmentCenter;
self.label.adjustsFontSizeToFitWidth = YES;
[self addSubview:self.label];
}
return self;
}
@end
CustomCollectionView.h:
@interface CustomCollectionView : UICollectionView
@end
पूरी परियोजना मैं एक स्टोरीबोर्ड इस्तेमाल किया के लिए और एक सामान्य UIViewController
। इस दृश्य नियंत्रक पर मैंने इंटरफ़ेस बिल्डर में UICollectionView
जोड़ा। मैंने अपने व्यू कंट्रोलर के साथ संग्रह दृश्य से आउटलेट कनेक्ट किया है और मेरे व्यू कंट्रोलर को डेटासेट और प्रतिनिधि विधियों को फिर से स्थापित किया है। मैंने इंटरफेस बिल्डर में UICollectionViewCell
और पुन: उपयोग पहचानकर्ता की कस्टम क्लास भी सेट की है।
तो सबकुछ काम करना चाहिए लेकिन मुझे केवल एक ब्लैक स्क्रीन मिलती है। मुझे क्या याद आ रहा है आप पूरी परियोजना here डाउनलोड कर सकते हैं।
यदि आप पृष्ठभूमि को बंद करना चाहते हैं कान, आपको 'collectionView.backgroundColor = [UIColor clearColor];' और 'collectionView का उपयोग करना होगा।backgroundView = [[UIView alloc] initWithFrame: CGRectZero]; ' – Multinerd