Unable to dequeue a cell with Identifier cell-must register a nib or a class for the identif

Source: Internet
Author: User

Differences:

 
-(ID) Dequeuereusablecellwithidentifier :( nsstring *) Identifier;-(ID) Dequeuereusablecellwithidentifier :( nsstring *) identifier forindexpath :( nsindexpath *) Indexpath ns_available_ios (6_0 );//Newer

1. The second method cannot run in sdk5.0.
2. If you need to use this method, you must use the following two methods:

 

 1   //  Beginning in iOS 6, clients can register a nib or class for each cell.  2   // If all reuse identifiers are registered, use the newer-dequeuereusablecellwithidentifier: forindexpath: to guarantee that a cell instance is returned.  3   //  Instances returned from the new dequeue method will also be properly sized when they are returned.  4 -( Void ) Registernib :( uinib *) nib forcellreuseidentifier :( nsstring * ) Identifier ns_available_ios (5_0 );  5 -( Void ) Registerclass :( class) cellclass forcellreuseidentifier :( nsstring *) identifier ns_available_ios (6_0 );

 

Pay attention to the comment above.
3. For example, you have used nib as a cell or customized a cell. When you create a uitableview

 
1Self. tableview. backgroundcolor =Xxxx;2[Self. tableview registerclass: [customcellClass] Forcellreuseidentifier:@"Customcell"];

In this way

 
-(Uitableviewcell *) tableview :( uitableview *) tableview cellforrowatindexpath :( nsindexpath *) indexpath

In this method, you can saveCode:

1StaticNsstring * cellidentifier =@"Cell";2If(Cell =Nil ){3Cell =[[Uitableviewcell alloc] initwithstyle: uitableviewcellstyledefault reuseidentifier: cellidentifier];4//Set your cell5}

Instead, you only need

Uitableviewcell * cell = [tableview dequeuereusablecellwithidentifier:@"Cell"Forindexpath: indexpath];

 

 

 

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.