-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) if the indexPath is not executed, uitableviewcell

Source: Internet
Author: User

-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) if the indexPath is not executed, uitableviewcell

-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) there are only three reasons why indexPath is not executed.

1. If delegate is not set, you must have self. tableView. delegate = self.

2. The number of sections and rows is returned as 0, or there is a conflict.

3. There is a problem with the frame of tableView, such as bit (0, 0, 0)

 

I encountered a strange problem, because I like to add constraints in the code, so they are all first

InitWithFrame: CGRectZero, and then add constraints. In this way, when initializing tableView, its frame is (0, 0, 0, 0), so cellForRowAtIndexPath is not executed.

Later I thought about some methods, and there was always a problem. Later I found:

The added constraint does not take effect in viewDidLoad and viewWillAppear. It only takes effect in viewDidAppear. This may be the disadvantage of adding constraints to the code.

Related Article

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.