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