I have a table view (without scrolling) inside a UIPopoverController which has 4 cells. And sometimes it needs to have an extra cell (1 max). If I am animating the adding and subtracting of that cell, can I update the popover's height as well?
Here is how I create the popover table view:
- (void)createPopoverTable
{
//set up array
_arrayList = [NSMutableArray arrayWithObjects:#"one", #"two", #"three", #"four", nil];
//Make row selections persist.
self.clearsSelectionOnViewWillAppear = NO;
//View height
NSInteger rowsCount = [_arrayList count];
NSInteger singleRowHeight = [self.tableView.delegate tableView:self.tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
NSInteger totalRowsHeight = (rowsCount * singleRowHeight) + 20;
//View width
CGFloat largestLabelWidth = 0;
for (NSString *item in _arrayList) {
//check size of font using default label
CGSize labelSize = [item sizeWithFont:[UIFont boldSystemFontOfSize:20.0f]];
if (labelSize.width > largestLabelWidth) {
largestLabelWidth = labelSize.width;
}
}
//some padding for the width
CGFloat popoverWidth = largestLabelWidth + 200;
//Tell popover the size
self.contentSizeForViewInPopover = CGSizeMake(popoverWidth, totalRowsHeight);
}
Then in one of my methods I have this code for when the table needs to change:
[self.tableView beginUpdates];
//update the array
[_arrayList insertObject:#"Blue" atIndex:3];
//insert the row
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:3 inSection:0]] withRowAnimation:UITableViewRowAnimationTop];
[self.tableView endUpdates];
The code all "works" fine but when I add the extra cell, it is being cut off due to the non scrolling nature of my popover controller. Any way I can update that?
try this one it worked for me
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.contentSizeForViewInPopover = self.tableView.contentSize;
}
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.popoverControllerContainer setPopoverContentSize:self.contentSizeForViewInPopover animated:YES];
}
Related
I am working on a custom keyboard app and have encountered a difficult problem. I have inquired about some documents, but unfortunately did not find the answer. I want to ask everyone to help me.
The problem is this, when I type in the keyboard, the input results will be displayed in the candidate column.I use the UICollectionView to create the candidate column.
- (void)createCandideteColection {
if (!_collectionView) {
CGFloat height = self.frame.size.height-pinyinHeight-lineHeight;
CGFloat y = pinyinHeight+lineHeight;
CGFloat showButtonH = height;
CGFloat candidateShowWidth = self.frame.size.width - showButtonH;
UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
flow.minimumInteritemSpacing = 20;
flow.minimumLineSpacing = 20;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, y, candidateShowWidth, height) collectionViewLayout:flow];
_collectionView.backgroundColor = [UIColor whiteColor];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.bounces = NO;
_collectionView.showsHorizontalScrollIndicator = NO;
[_collectionView registerClass:[GZCandidateCell class] forCellWithReuseIdentifier:#"candidateCell"];
[self addSubview:_collectionView];
}
}
Sets the frame of the cell, _data changes with the input (each time a text is entered, _data changes once, and [collectionView reloadData] is called once).The width of the cell changes with the number of characters entered.
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
NSString *str = _data[indexPath.row];
CGFloat height = self.frame.size.height-pinyinHeight-lineHeight;
CGFloat width = str.length * 20 + 10;
return CGSizeMake(width, height);
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
GZCandidateCell *cell = (GZCandidateCell*)[collectionView dequeueReusableCellWithReuseIdentifier:#"candidateCell" forIndexPath:indexPath];
NSString *str = _data[indexPath.row];
[cell setTitleText:str];
return cell;
}
Assign titleLabel value, titleLabel size will be recalculate when calling [cell setTitleText:str].
when [collectionView removeFromSuperview] is called, collectionView will be destroyed,but there is little memory that cannot be released.Every time the input is completed and the collectionView is removed, some memory will not be released and will become a larger number after it is accumulated.
The reason why I will eventually locate this problem on the collectionView is because I don't create this collectionView, the memory does not grow.
Get input data and show on the collectionView,and tabBar is the candidate column I mentioned above:
if (!_textKeyboard) {
_textKeyboard = [[GZQwertyKeyboard alloc] initWithFrame:CGRectMake(0, navigaitonHeight, SCREEN_WIDTH, height) andKeyboardType:type];
_textKeyboard.backgroundColor = Color_background_kb;
[self.view addSubview:_textKeyboard];
}
__weak KeyboardViewController *weakSelf = self;
__weak GZQwerty *getdata = [GZQwerty defaultQwerty]; //init qwerty
_textKeyboard.sendSelectedStr = ^(NSString *text) {
if (!weakSelf.tabBar) {
[weakSelf addCandidateBarView];
}
int asciiCode = [text characterAtIndex:0];
[getdata sendInput:asciiCode complation:^(NSString *compontText, NSArray *candiateArray) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.tabBar changeShowText:candiateArray];
});
}];
};
Call [weakSelf addCandidateBarView] to create the tabBar.Call [weakSelf.tabBar changeShowText:candiateArray] to modify the data source of the collectionView and refresh the collectionView.Like this:
- (void)changeShowText:(NSArray*)textArr {
_data = textArr;
if (!_collectionView) {
[self createCandideteColection];
}
[_collectionView reloadData];
[_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
}
When the keyboard is typed, if changeShowText: is not called, the memory is stable and there is no memory growth.
So, can anyone help me? Is there a better way than collectionView or how to avoid memory growth?Is it caused by repeated changes to the width of the cell?
When I attempt to update my table **UITableview** using the code below my cells become smaller. I was wondering if anyone has faced the same problem and would know why this is happening.
NSMutableArray* indexPaths = [[NSMutableArray alloc] init];
for (int i = 20; i < 20 + 20; i++) {
[indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
}
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimationBottom)];
[self.tableView endUpdates];
....
#CreativityKills.
if your auto layout is on please try following method to add after add rows. It may help you if it was a problem of auto-layout.
NSMutableArray* indexPaths = [[NSMutableArray alloc] init];
for (int i = 20; i < 20 + 20; i++) {
[indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
}
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimationBottom)];
[self.tableView endUpdates];
[self adjustHeightOfTableview];
- (void)adjustHeightOfTableview
{
CGFloat height = self.tableView.contentSize.height;
CGFloat maxHeight = self.tableView.superview.frame.size.height - self.tableView.frame.origin.y;
// if the height of the content is greater than the maxHeight of
// total space on the screen, limit the height to the size of the
// superview.
if (height > maxHeight)
height = maxHeight;
// now set the height constraint accordingly
[UIView animateWithDuration:0.25 animations:^{
self.tableViewHeightConstraint.constant = height;
[self.view setNeedsUpdateConstraints];
}];
}
Hope this may help you.
May be you have not given implementation for UITableViewDelegate method:
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
return 44.0;//your default row height
}
I have a dynamic tableView with custom cells that each contain a textField and label. I want the following behavior:
A user taps the "Add" button, and the table inserts a cell at index 0, with the cell's textField becoming the first responder.
When the user finishes inputting data, the one-lined textField resigns as first responder and hides itself.
The cell's label then becomes visible, filled with the user input, and auto-resizes it's height to accommodate the input. The cell is resized at this time too.
I have code that does exactly this the first time a cell is added, but when more cells are added then it gets weird. The second added cell
s textField does not become first responder and is filled with the text from the previous textField. Subsequent added cells appear blank, except every 6 blank cells, the first cell's text shows up.
What's going on, and how can I fix this?
Edit: Thanks to #Rayfleck, I have resolved the issue of the second added cell being filled with the text from the previous textField, but the second cell that gets added (and subsequent added cells) still isn't becoming first responder.
Here's the demo showing this behavior:
Here's my code:
#define FONT_SIZE 16.0f
#define CELL_CONTENT_WIDTH 300.0f // This will change for different size!
#define CELL_CONTENT_MARGIN_WIDTH 10.0f
#define CELL_CONTENT_MARGIN_HEIGHT 20.0f
#interface ViewController ()
#property (strong) IBOutlet UITableView *tableView;
#property (strong) NSMutableArray *notesArray;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.notesArray = [NSMutableArray arrayWithObjects:#"Testo 1", #"This is a long string of text to show how the cell resizes to fit a variable height label.", #"Testo 3", #"Testo 4", #"Testo 5", nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (IBAction)addButtonTapped {
NSMutableArray *indexPaths = [NSMutableArray array];
[indexPaths addObject:[NSIndexPath indexPathForRow:0 inSection:0]]; // insert at first index
[self.tableView setEditing:YES animated:NO]; // go into edit mode so cell has label hidden and textField visible
// do the insertion
[self.notesArray insertObject:#"" atIndex:0]; // placeholder for when user starts typing
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationTop];
[self.tableView endUpdates];
[self.tableView setEditing:NO animated:NO];
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
NSIndexPath *path = [NSIndexPath indexPathForRow:0 inSection:0]; // first table cell
HC_NoteCell *cell = (HC_NoteCell *)[self.tableView cellForRowAtIndexPath:path];
cell.noteTextField.hidden = YES;
cell.noteLabel.text = cell.noteTextField.text;
cell.noteLabel.hidden = NO;
[self.notesArray replaceObjectAtIndex:0 withObject:cell.noteTextField.text];
[textField resignFirstResponder];
// Need to reload rows so cell height can be recalculated
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:#[path] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
return YES;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.notesArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *text;
text = [self.notesArray objectAtIndex:indexPath.row];
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN_WIDTH * 2), 20000.0f);
UIFont *font = [UIFont fontWithName:#"Helvetica Neue" size:FONT_SIZE];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
forKey:NSFontAttributeName];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:text attributes:attrsDictionary];
CGRect paragraphRect = [attributedString boundingRectWithSize:constraint options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) context:nil];
CGFloat height = MAX(paragraphRect.size.height, 22.0f);
return height + (CELL_CONTENT_MARGIN_HEIGHT * 2);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"NoteCell";
HC_NoteCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[HC_NoteCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (self.tableView.isEditing) {
cell.noteLabel.hidden = YES;
cell.noteTextField.hidden = NO;
cell.noteTextField.delegate = self;
[cell.noteTextField becomeFirstResponder];
} else {
cell.noteLabel.hidden = NO;
cell.noteTextField.hidden = YES;
cell.noteTextField.delegate = self;
cell.noteLabel.text = [self.notesArray objectAtIndex:indexPath.row];
}
return cell;
}
#end
If you are reusing/dequeing cells, then in cellForRowAtIndexPath, you must set the new value for every subview of the cell, because it will probably contain the contents of the previous cell.
So cell.noteLabel.text = nil; in all cases, and then in your else case, set it's value from the array.
I want to add rows to a tableview with begin/endUpdates to prevent the jump of the tableview when i do reloadData
this is my code
- (void)updateTableWithNewRowCount:(NSInteger)rowCount
andNewData:(NSArray *)newData {
// Save the tableview content offset
CGPoint tableViewOffset = [self.messagesTableView contentOffset];
// Turn of animations for the update block
// to get the effect of adding rows on top of TableView
[UIView setAnimationsEnabled:NO];
[self.messagesTableView beginUpdates];
NSMutableArray *rowsInsertIndexPath = [[NSMutableArray alloc] init];
int heightForNewRows = 0;
for (NSInteger i = 0; i < rowCount; i++) {
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
[rowsInsertIndexPath addObject:tempIndexPath];
// [self.messages insertObject:[newData objectAtIndex:i] atIndex:i];
[self addMessage:[newData objectAtIndex:i]];
heightForNewRows =
heightForNewRows + [self heightForCellAtIndexPath:tempIndexPath];
}
[self.messagesTableView insertRowsAtIndexPaths:rowsInsertIndexPath
withRowAnimation:UITableViewRowAnimationNone];
tableViewOffset.y += heightForNewRows;
[self.messagesTableView endUpdates];
[UIView setAnimationsEnabled:YES];
[self.messagesTableView setContentOffset:tableViewOffset animated:NO];
}
And sometimes (not everytime) I get this error
invalid number of rows in section 0.
The number of rows contained in an existing section after
the update (2) must be equal to the number of rows contained in that section
before the update (2), plus or minus the number of rows inserted or deleted
from that section (2 inserted, 0 deleted) and plus or minus the number of
rows moved into or out of that section (0 moved in, 0 moved out).
How do i prevent this error ?
if you dont want animation then use directly
- (void)updateTableWithNewRowCount:(NSInteger)rowCount
andNewData:(NSArray *)newData {
// Save the tableview content offset
CGPoint tableViewOffset = [self.messagesTableView contentOffset];
// Turn of animations for the update block
// to get the effect of adding rows on top of TableView
NSMutableArray *rowsInsertIndexPath = [[NSMutableArray alloc] init];
int heightForNewRows = 0;
for (NSInteger i = 0; i < rowCount; i++) {
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
[rowsInsertIndexPath addObject:tempIndexPath];
// [self.messages insertObject:[newData objectAtIndex:i] atIndex:i];
[self addMessage:[newData objectAtIndex:i]];
heightForNewRows =
heightForNewRows + [self heightForCellAtIndexPath:tempIndexPath];
}
tableViewOffset.y += heightForNewRows;
[self.messagesTableView reloadData];
[self.messagesTableView setContentOffset:tableViewOffset animated:NO];
}
If you want to quickly jump to a selected indexPath (with or without animation), you can use this function:
//My function to populate
//tableView is synthesized
-(void)setNewMessage:(NSString*)message{
// ...
NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];
// if your selectedIndexPath==nil, the table scroll stay in the same position
[self reloadData:selectedIndexPath animated:NO];
}
//My reload data wrapper
-(void)reloadData:(NSIndexPath *)selectedIndexPath animated:(BOOL)animated{
[tableView reloadData];
// atScrollPosition can receive different parameters (eg:UITableViewScrollPositionMiddle)
[tableView scrollToRowAtIndexPath:selectedIndexPath
atScrollPosition:UITableViewScrollPositionTop
animated:animated];
}
Once I needed that same flexibility in a tableView and this function has met my needs. You don`t need the "setAnimationsEnabled", just use:
[tableView scrollToRowAtIndexPath:nil
atScrollPosition:UITableViewScrollPositionNone
animated:NO];
];
I hope it helped.
Try this, I am not sure whether this will work or not.
- (void)updateTableWithNewRowCount:(NSInteger)rowCount
andNewData:(NSArray *)newData {
// Save the tableview content offset
CGPoint tableViewOffset = [self.messagesTableView contentOffset];
// Turn of animations for the update block
// to get the effect of adding rows on top of TableView
[UIView setAnimationsEnabled:NO];
NSMutableArray *rowsInsertIndexPath = [[NSMutableArray alloc] init];
int heightForNewRows = 0;
for (NSInteger i = 0; i < rowCount; i++) {
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
[rowsInsertIndexPath addObject:tempIndexPath];
// [self.messages insertObject:[newData objectAtIndex:i] atIndex:i];
[self addMessage:[newData objectAtIndex:i]];
heightForNewRows = heightForNewRows + [self heightForCellAtIndexPath:tempIndexPath];
}
tableViewOffset.y += heightForNewRows;
[UIView setAnimationsEnabled:YES];
[self.messagesTableView setContentOffset:tableViewOffset animated:NO];
double delayInSeconds = 1.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.messagesTableView beginUpdates];
[self.messagesTableView insertRowsAtIndexPaths:rowsInsertIndexPath
withRowAnimation:UITableViewRowAnimationNone];
[self.messagesTableView endUpdates];
});
}
Note: You might require to update rowsInsertIndexPath reference to use inside the block (__block type).
Working in iOS 7, how does one specify where the header & footer boxes go in a UICollectionView?
I have a custom UICollectionViewFlowLayout. I have overwritten
-(void)prepareLayout
-(NSArray*) layoutAttributesForElementsInRect:(CGRect)rect
-(UICollectionViewLayoutAttributes*) layoutAttributesForSupplementaryViewOfKind: (NSString*)kind atIndexPath:(NSIndexPath*)indexPath
My problem is, I'm not sure how to specify header location. I have already specified that a header exists in prepareLayout:
-(void)prepareLayout
{
[super prepareLayout];
boundsSize = self.collectionView.bounds.size;
midX = boundsSize.width / 2.0f;
curIndex = 0;
self.headerReferenceSize = CGSizeMake(CELL_SIZE, TITLE_HEIGHT);
self.footerReferenceSize = CGSizeMake(0, 0);
self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
self.sectionInset = UIEdgeInsetsMake(TOP_INSET, LEFT_INSET, BOTTOM_INSET, RIGHT_INSET);
self.minimumLineSpacing = LINE_SPACING;
self.minimumInteritemSpacing = INTERIM_SPACING;
self.itemSize = CGSizeMake(CELL_SIZE, CELL_SIZE);
}
I just don't know the right property of my custom FlowLayout to set, as there doesn't seem to be something like "HeaderLocation" to set, either as a LayoutAttributes or in the layout object itself. Right now, it is appearing to the side/between my images, when I'd like them to be appearing above each image (horizontal scroll).
I have tried the following:
-(UICollectionReusableView*) collectionView: (UICollectionView*)collectionView viewForSupplementaryElementOfKind:(NSString*)kind atIndexPath:(NSIndexPath*)indexPath
{
NSLog(#"**ViewForSupplementaryElementOfKind called***");
CGFloat centerX = collectionView.center.x;
CGFloat centerY = collectionView.center.y;
CGFloat titleWidth = [MyLayout titleWidth];
CGFloat titleHeight = [MyLayout titleHeight];
MyTitleView* titleView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:ImageTitleIdentifier forIndexPath:indexPath];
titleView.frame = CGRectMake(centerX - titleWidth/2.0,
0.0,
titleWidth,
titleHeight);
return titleView;
}
This doesn't work. The title appears above overlapped with a bunch of other titles, then the moment I start scrolling (horizontally), they jump back into the wrong place, horizontally between the images rather than above.
PS> Please do not suggest anything that has to do with NIB or XIB placement. I am using a UICollectionView, NOT a UICollectionViewController, so I actually have no prototypical cell to work with. The layout is being done entirely programatically -- from code alone -- so I can't simply open a XIB file and adjust the location of a text box.
Amending the attributes returned by -layoutAttributesForElementsInRect is the right approach, but if you want to alter the position of offscreen headers and footers, you may need to fetch the supplementary view attributes yourself.
For example, in your UICollectionViewFlowLayout subclass:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
NSMutableArray *attributesArray = [[super layoutAttributesForElementsInRect:rect] mutableCopy];
// the call to super only returns attributes for headers that are in the bounds,
// so locate attributes for out of bounds headers and include them in the array
NSMutableIndexSet *omittedSections = [NSMutableIndexSet indexSet];
for (UICollectionViewLayoutAttributes *attributes in attributesArray) {
if (attributes.representedElementCategory == UICollectionElementCategoryCell) {
[omittedSections addIndex:attributes.indexPath.section];
}
}
for (UICollectionViewLayoutAttributes *attributes in attributesArray) {
if ([attributes.representedElementKind isEqualToString:UICollectionElementKindSectionHeader]) {
[omittedSections removeIndex:attributes.indexPath.section];
}
}
[omittedSections enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:idx];
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader
atIndexPath:indexPath];
[attributesArray addObject:attributes];
}];
for (UICollectionViewLayoutAttributes *attributes in attributesArray) {
if ([attributes.representedElementKind isEqualToString:UICollectionElementKindSectionHeader]) {
// adjust any aspect of each header's attributes here, including frame or zIndex
}
}
return attributesArray;
}
CollectionView Header height is set below Collectionview delegate
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
And Set view in Collectionview Header in Below Delegate
- (UICollectionReusableView*)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView * view = nil;
if ([kind isEqualToString:UICollectionElementKindSectionHeader])
{
ColorSectionHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:NSStringFromClass([ColorSectionHeaderView class])
forIndexPath:indexPath];
header.sectionIndex = indexPath.section;
header.hideDelete = collectionView.numberOfSections == 1; // hide when only one section
header.delegate = self;
view = header;
}
return view;
}
Ragistred Class in ViewDidLoad
-(void)ViewDidLoad
{
[collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([ColorSectionFooterView class]) bundle:nil]
forSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:NSStringFromClass([ColorSectionFooterView class])];
[Super ViewDidLoad];
}