ios - Separator lines for UITableViewCellStyleSubtitle cells not taking the full width -


i have prepared a simple test project question @ github.

when using uitableviewcellstylesubtitle type of cells (called subtitle in xcode interface builder) - reason horizontal lines not reaching left side of screen:

app screenshot

at above screenshot can see separator lines in "empty cells" occupying whole width fine.

first thought icons (size: 46 x 46 pixels) not fitting cells , tried increase row height, not help.

also have tried set custom insets custom , there left 0 pixels (both table view , mycell), there still gap on left side:

xcode screenshot

here source code of tableviewcontroller.m:

- (void)viewdidload {     [super viewdidload];      self.items = [[nsmutablearray alloc] initwitharray:@[         @{@"title": @"title 1", @"subtitle": @"sub title 1", @"icon": @"signal4.png"},         @{@"title": @"title 2", @"subtitle": @"sub title 2", @"icon": @"signal1.png"},         @{@"title": @"title 3", @"subtitle": @"sub title 3", @"icon": @"signal2.png"},         @{@"title": @"title 4", @"subtitle": @"sub title 4", @"icon": @"signal3.png"}     ]]; }  #pragma mark - table view data source - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return 1; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return self.items.count; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"mycell" forindexpath:indexpath];      nsdictionary* item = [self.items objectatindex:indexpath.row];     cell.textlabel.text = item[@"title"];     cell.detailtextlabel.text = item[@"subtitle"];     uiimage* icon = [uiimage imagenamed:item[@"icon"]];     [cell.imageview setimage:icon];      return cell; } 

update: source code answer has helped me @ end: ios 8 uitableview separator inset 0 not working

fixed screenshot

-(void)tableview:(uitableview *)tableview willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath {     // remove seperator inset     if ([cell respondstoselector:@selector(setseparatorinset:)]) {            [cell setseparatorinset:uiedgeinsetszero];     }      // prevent cell inheriting table view's margin settings     if ([cell respondstoselector:@selector(setpreservessuperviewlayoutmargins:)]) {         [cell setpreservessuperviewlayoutmargins:no];     }      // explictly set cell's layout margins     if ([cell respondstoselector:@selector(setlayoutmargins:)]) {         [cell setlayoutmargins:uiedgeinsetszero];     } }  /* -(void)viewdidlayoutsubviews {     [super viewdidlayoutsubviews];      // force tableview margins (this may bad idea)     if ([self.tableview respondstoselector:@selector(setseparatorinset:)]) {         [self.tableview setseparatorinset:uiedgeinsetszero];     }      if ([self.tableview respondstoselector:@selector(setlayoutmargins:)]) {         [self.tableview setlayoutmargins:uiedgeinsetszero];     } }  */ 

add table view separator insets zero. not table view cell.

enter image description here

add code in cellforrowatindexpath:

-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     //....     if ([[[uidevice currentdevice]systemversion]floatvalue]>=8.0)     {         cell.layoutmargins = uiedgeinsetszero;         cell.preservessuperviewlayoutmargins = no;     } } 

integration code :

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"mycell" forindexpath:indexpath];      if ([[[uidevice currentdevice]systemversion]floatvalue]>=8.0)     {         cell.layoutmargins = uiedgeinsetszero;         cell.preservessuperviewlayoutmargins = no;     }      nsdictionary* item = [self.items objectatindex:indexpath.row];     cell.textlabel.text = item[@"title"];     cell.detailtextlabel.text = item[@"subtitle"];     uiimage* icon = [uiimage imagenamed:item[@"icon"]];     [cell.imageview setimage:icon];      return cell; } 

see preview :

enter image description here


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -