iOS 8 : layoutMargins property on cells AND table views.

Depuis iOS 8, Apple a ajouté une nouvelle propriété permettant de configurer pour chaque cell
ses margins
. Un point très intéressant pour faire ressortir certaines cells dans un tableView
.
Cependant, si vous souhaitez mettre l'intégrallité de ces nouvelles marges à 0, tableView
comme Cells
, pour retrouver votre liste simple comme avant, voici un petit Snippet glané dans différents posts StackOverFlow.
/*************************************************/
// Design protection for IOS 7 & 8
/*************************************************/
-(void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
That's all !