IOS8 introduce a new concept named Configuring Content Margins , a new property named layoutMargins is also introduced , for the details of the property , please refer to the Apple Doc . The type of layoutMargins is UIEdgeInsets , by default the value is {8,8,8,8} . To remove the seperator line of TableView in IOS8 , in addition to set tableView.seperatorInset = UIEdgeInsetsZero
, you must also do as :
First define the macro
#define isIOS8SystemVersion (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
In the UITableViewDelegate method add :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseId = @"cellReuseID" ;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId];
if(!cell){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseId];
if(isIOS8SystemVersion){
cell.layoutMargins = UIEdgeInsetsZero;
cell.preservesSuperviewLayoutMargins =NO ;
}
}
Doing these will remove the seperator line . You can also do as follow :
UITableView *tableView = [[UITableView alloc] init];
if(isIOS8SystemVersion){
tableView.layoutMargins = UIEdgeInsetsZero ;
}
and in the UITableViewDelegate method add :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseId = @"cellReuseID" ;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId];
if(!cell){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseId];
if(isIOS8SystemVersion){
cell.layoutMargins = UIEdgeInsetsZero;
}
}