iphone - How to Set a Space between Tableview Cell in iOS? -


I am a newbie in iOS development and I know that this question has been asked many times, but I am confused for it. I want to know how to set a location between the UITWView cell in the section. In my app there are two sections in the UITWV, the first section contains only one data value, so there is no problem. But in my second section there are 5 to 7 data values, but there is no space between them, which is how to set the location in the footer between the second section cell in the UITableView.

OK, there are two ways for your class

  - (UIView *) tableView: (UITableView *) tableView viewForHeaderInSection: (NSInteger) section  

and

  - (UIView *) tableView: (UITableView *) TableView viewForFooterInSection  

but not intended to place space among cells in the same section.

There are two options for my money ... the first and most complex / hacky

  1. The - (NSInteger) numberOfSectionsInTableView: (UITableView *) tableView you can return the number of cells in the second section and put data cellForRowAtIndexPath if (section == 0) in the usual way ... else you can pull information from an array or instead [theAraray objectAtIndex: indexPath.section] using

  2. ( Very simple and better practice) .. Create a UITableViewCelL subclass and try C that your in cellForRowAtIndexPath so

      (UITableViewCell *) like tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {static NSString * CellIdentifier = @ "Cell"; Fixed NSString * MyCellIdentifier = @ "MyCustomCell"; Switch (indexPath.section) {case0: {UITableViewCell * cell = [tableview dequreableCalewite identifier: cell identifier]; If (! Cell) cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier]; // Setup your 1 segment cells return here cell; } Default: {MYTableViewCell * cell = [tableview] dequeueReusableCellWithIdentifier: MyCellIdentifier]; If (! Cell) cell = [[[MYTableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: MyCellIdentifier]; // Here all other layout code if indexPath.row == 0 returns the cell; }}  

In your custom cell you can set the m

  - (Zero) Layout Subviews {[Super Layout Switches]; Self.imageView.frame = CGRectMake (0,0,0,0,0,0); // Top / middle in your cell / place them out. Self.textLabel.frame = CGRectMake (0,0,0,0,0,0); // which will allow for some space on the floor / sides}  

So use the end

  - (CGFloat) tableView: (UITableView *) TableView heightForRowAtIndexPath: (NSIndexPath *) index path {if (indexPath.section == 0) back to THE_CELL_HEIGHT; AND THE_CELL_HEIGHT + PADDING; }  

In this way, you can set padding in the cell, which is cleaner and reusable (UITableViewCellStyle) style reuseIdentifier: (NSString *) reuseIdentifier

 >  

and using the code> add them [ Self.contentView addSubView: someView]; You can always set [UIColor background color ClearColor of a cell]; If you have an image / content behind the table / view


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -