After upgrading to XCode6, IOS8 set TableView's Setseparatorinset:uiedgeinsetszero not working solution

Source: Internet
Author: User

First we drag and drop a default TableView control! Look at the inspector of the Xcode5 Panel (inspector)

We can find a Separator insetss tag defaults to the default

We chose to find a custom at this time we are surprised to find that left 15, when we just change this 15 to 0, and then save, you will find the TableView line is the same as before.

Some friends asked if the code is written tableview.

Let's go on to analyze this problem and ask us to query the next TableView delegate we'll find that iOS7 adds some new properties,

@property (nonatomic) uiedgeinsets separatorinset ns_available_ios ( 7_0)ui_appearance_selector; Allows customization of the frame of cell separators

This time you should find out whether the word separatorinset is a bit familiar, Apple has given a comment, you can customize the View cell division line,

Uiedgeinsets is a struct type, and then we find the property we want left.

typedef struct Uiedgeinsets {

cgfloat Top, left, bottom, right;//Specify amount to inset (positive) for each of the edges. Values can Negat Ive to ' outset '

} uiedgeinsets;

When we use TableView, we find that the left side of the split line is shorter and can usually be solved using Setseparatorinset:uiedgeinsetszero. But after upgrading to XCode6, the iOS8 found no effect. Here are the solutions:

First, add the following code to the Viewdidload method:

if ([Self.tableview respondstoselector: @selector (setseparatorinset:)]) {

[Self.tableview Setseparatorinset:uiedgeinsetszero];

}

if ([Self.tableview respondstoselector: @selector (setlayoutmargins:)]) {

[Self.tableview Setlayoutmargins:uiedgeinsetszero];

}

Then add the following code to the Willdisplaycell method:

-(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];

}

}

This will show up normally.

After upgrading to XCode6, IOS8 set TableView's Setseparatorinset:uiedgeinsetszero not working solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.