Crash issues caused by IOS UITableView

Source: Internet
Author: User

In fact, UITableView should be the most frequent use of a control in iOS development, a chat joke between colleagues said "a page, if you do not use UITableView, it is not called a page." Although it is the most common control, his strength is undeniable and a high-error control.

1.

In fact, this method has been around for a long time, but I would like to accept the new things less ability of people, or not used to.

Use this method to use a companion

-(void) registernib: (Nullable uinib *) nib Forcellreuseidentifier: (NSString *) identifier Ns_available_ IOS (5_0); -(void) RegisterClass: (Nullable Class) Cellclass forcellreuseidentifier: (NSString *) identifier ns_available _ios (6_0);

Need to register in front of the cell, and then use, the specific method on the web should have a lot of introduction, here I will not say, so use the code is very neat.

However, it is necessary to note that if you do not register with the advanced line, it will cause a crash.

The first flashback to be explained today is the cause of this,

Self.tableView.separatorStyle = Uitableviewcellseparatorstylenone;

The above code looks normal, but the main character that causes the flashback today is it, because it adds the wrong position.

it was placed before registering the cell. , TableView in the setting of the split line, found its own cell, found that the cell did not, and then caused the flash back.

Solution to the

Self.tableView.separatorStyle = Uitableviewcellseparatorstylenone; put in

After the registe is ready;

2.layout caused by the flash back

-(void) layoutsubviews{    [Super Layoutsubviews];}

Hey!!! is a very common code ah, although the predecessors often educate us, do not deal with too much logic here, code, but we still like to put a lot of code, especially the effect on this inside, because it is really useful.

But here is easy to use is good, but can not be used, here to tell the truth, is really should not put too much processing, unless have to, and use the time also have to pay attention to the place, this time we flash together is in

[Super Layoutsubviews];

There are some autolayout operations behind, resulting in a crash

Above is I today and you share a bit of development problems encountered, welcome you master to add Ah, said the wrong place to correct!!!

Crash issues caused by IOS UITableView

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.