天天看點

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