Saturday, June 8, 2013

UITableViewCell UITableViewCellSeparatorStyleNone example in Objective C (iOS).


UITableViewCell UITableViewCellSeparatorStyleNone

Cell Separator Style
The style for cells used as separators.

typedef enum {
UITableViewCellSeparatorStyleNone,
UITableViewCellSeparatorStyleSingleLine,
UITableViewCellSeparatorStyleSingleLineEtched
} UITableViewCellSeparatorStyle;

Constants
UITableViewCellSeparatorStyleNone
The separator cell has no distinct style.
UITableViewCellSeparatorStyleSingleLine
The separator cell has a single line running across its width. This is the default value
UITableViewCellSeparatorStyleSingleLineEtched
The separator cell has double lines running across its width, giving it an etched look. This style is currently only supported for grouped-style table views.

Discussion of [UITableViewCell UITableViewCellSeparatorStyleNone]
You use these constants to set the value of the separatorStyle property defined by UITableView.

UITableViewCell UITableViewCellSeparatorStyleNone example.
- (void)viewDidLoad
{
 self.title = @"Fast Scrolling Example";
 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [super viewDidLoad];
}

Example of [UITableViewCell UITableViewCellSeparatorStyleNone].
First you can write the code:

{    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];}
after that

{    #define cellHeight 80 // You can change according to your req.<br>
     #define cellWidth 320 // You can change according to your req.<br>

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath  *)indexPath
    {
         UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seprater_line.png"]];
        imgView.frame = CGRectMake(0, cellHeight, cellWidth, 1);
        [customCell.contentView addSubview:imgView];
         return  customCell;

     }
}

UITableViewCell UITableViewCellSeparatorStyleNone example.
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

// We have to use the borderColor/Width as opposed to just setting the
// backgroundColor else the view becomes transparent and disappears during
// the cell's selected/highlighted animation
UIView *separatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 43, 1024, 1)];
separatorView.layer.borderColor = [UIColor redColor].CGColor;
separatorView.layer.borderWidth = 1.0;
[cell.contentView addSubview:separatorView];

End of UITableViewCell UITableViewCellSeparatorStyleNone example article.