天天看点

iOS7 cell分割线左对齐

IOS7中cell的分割线没有左对齐,若要解决这个问题,则:

首先,

判断IOS版本:

#define IOS_7 [[UIDevice currentDevice].systemVersion doubleValue]>6.2

然后,

在-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath中添加

if ([tableViewrespondsToSelector:@selector(setSeparatorInset:)] && IOS_7) {

            [tableViewsetSeparatorInset:UIEdgeInsetsZero];

        }

如下:

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

{

   staticNSString * CellIndentifier =@"cell";

   UITableViewCell * cell = [tableViewdequeueReusableCellWithIdentifier:CellIndentifier];

   if (cell ==nil) {

        cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIndentifier];

        //iOS7分割线适配

       if ([tableViewrespondsToSelector:@selector(setSeparatorInset:)] && IOS_7) {

            [tableViewsetSeparatorInset:UIEdgeInsetsZero];

        }

    }

   return cell;

}

问题解决!

转载请附博文地址:http://blog.csdn.net/u010681071/article/details/19492651