0

I am making an app in which i am using tableview. but i am stuck in some issue that is when i am setting text to my cell, separator line is showing after some space from left below is my screen shot first five cell showing spaces from left while remaining are ok

What i am mistaking ??? below is my sample code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;

}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *tableviewidentifier = @"Cell";
    UITableViewCell *cell= [self.tableview dequeueReusableCellWithIdentifier:tableviewidentifier];
    //cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellAccessoryDisclosureIndicator reuseIdentifier:tableviewidentifier];
    if(cell==nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableviewidentifier];
    }

    cell.textLabel.text=@"demo";

    return cell;

   }

Thanx in advance... please help as i am stuck in it :(

Mishal Awan
  • 724
  • 2
  • 11
  • 25

1 Answers1

1

You need to specify the inset if you want to use full width

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];

    if ([self.tableview respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableview setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([self.tableview respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableview setLayoutMargins:UIEdgeInsetsZero];
    } 
}

If using storyboard you can edit the inset as shown on this answer

enter image description here

Community
  • 1
  • 1
Vig
  • 1,532
  • 1
  • 12
  • 28