tableview-> attribule inspector -> separator -> single line
self.tableView.separatorColor = [UIColor whiteColor];
[self.tableView setBackgroundColor:[UIColor yellowColor]];
self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"table_background.png"]];
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
static NSString *CellIdentifier = @"SectionHeader";
UITableViewCell *headerView = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (headerView == nil){
[NSException raise:@"headerView == nil.." format:@"No cells with matching CellIdentifier loaded from your storyboard"];
}
return headerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 40.0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"forward" sender:indexPath];
}
cell.accessoryType = UITableViewCellAccessoryNone;
cell.contentView.alpha = 0.5;
//in viewdidload add:
self.tableView.separatorColor = [UIColor clearColor];
//in cellForRowAtIndexPath add
CALayer *separator = [CALayer layer];
separator.backgroundColor = [UIColor whiteColor].CGColor;
separator.frame = CGRectMake(0, -1, self.view.frame.size.width, 1);
[cell.layer addSublayer:separator];
if (indexPath.row == 0)
{
// we decide here that first cell in the table is not selectable (it's just an indicator)
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"editEvent" sender:[self.tableView cellForRowAtIndexPath:indexPath]];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UITableViewCell *cell = sender;
// Make sure your segue name in storyboard is the same as this line
NSLog(@"inside prepare for segue");
if ([[segue identifier] isEqualToString:@"editEvent"])
{
//((BTCSegue *)segue).animationType = 0 ;
// Get reference to the destination view controller
llEditLogViewController *editViewController = [segue destinationViewController];
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
NSInteger rowSelected = [indexPath row];
editViewController.rowSelected = rowSelected;
NSLog(@"prepare for segue, and row is %ld",(long)rowSelected);
}
}
### how to rename delete table view cell "Delete"?
```objective-c
//let's say we want to rename it to close
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"Close";
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return [UIView new];
// If you are not using ARC:
// return [[UIView new] autorelease];
}
https://github.com/John-Lluch/SWRevealViewController/issues/104
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return YES - we will be able to delete all rows
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Perform the real delete action here. Note: you may need to check editing style
// if you do not perform delete only.
NSLog(@"Deleted row.");
}
//normally replace the arrow with an image
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"disclosureIndicator.png"]];
// use self.tableview insead of tableview when dequeue with identifier
UITableViewController *tbc = (UITableViewController *)self.childViewControllers[0];
[tbc.tableView reloadData];
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
if([view isKindOfClass:[UITableViewHeaderFooterView class]]){
UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView *) view;
NSString *tempStr = [tableViewHeaderFooterView.textLabel.text lowercaseString];
tempStr = [tempStr stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[tempStr substringToIndex:1] uppercaseString]];
NSLog(@"temp Str is %@", tempStr);
tableViewHeaderFooterView.textLabel.text = tempStr;
}
}
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
int lastRow=[tableArray count];
if([indexPath row] == lastRow)
{
NSLog(@"going to load more");//implement your load more function
[self.tableView reloadData];
[self.tableView setNeedsDisplay];
}
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
http://www.appcoda.com/pull-to-refresh-uitableview-empty/
http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout