Saturday, June 8, 2013

UITableViewCell UITableViewCellSeparatorStyleSingleLine example in Objective C (iOS).


UITableViewCell UITableViewCellSeparatorStyleSingleLine

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 UITableViewCellSeparatorStyleSingleLine]
You use these constants to set the value of the separatorStyle property defined by UITableView.

UITableViewCell UITableViewCellSeparatorStyleSingleLine example.
  [TableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];

  [TableView setSeparatorColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Divider_line@2x.png"]]];

Example of [UITableViewCell UITableViewCellSeparatorStyleSingleLine].
if ([[self.fetchedResultsController fetchedObjects] count] == 0)
{
    self.routineTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.routineTableView.separatorColor = [UIColor clearColor];
}
else
{
     self.routineTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; // or you have the previous 'None' style...
    self.routineTableView.separatorColor = [UIColor grayColor];
}

UITableViewCell UITableViewCellSeparatorStyleSingleLine example.
static NSString *cellIdentifier = @"cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if(cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellSeparatorStyleSingleLine reuseIdentifier:cellIdentifier] autorelease];
}

End of UITableViewCell UITableViewCellSeparatorStyleSingleLine example article.