UITableView line seperator visible for alternative

2019-02-25 21:41发布

问题:

I am facing issue for UITableView line separator. Line is visible for alternative rows.

Adding UIView with height 1 to the cell will give the solution but this is not the correct way. And the below code is working perfect for iOS 8 but in 9 it's showing different nature.

- (IBAction)curencySelect:(id)sender {
    currencyTable = [[UITableView alloc]initWithFrame:CGRectMake(29, 257, 265,113) style: UITableViewStylePlain];
}
#pragma mark -
#pragma mark UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return 1;
}

- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section{


    return currencyArray.count;

}

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


       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];

       if (cell == nil) {

            cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"];
       }



    cell.textLabel.text = [currencyArray objectAtIndex:indexPath.row];

    return cell;
}

Thanks in advance.

回答1:

Common problems with the simulator, which can't always display 1 pixel views. Set scale to 100% in Window->Scale.