Chapter 9 editing uitableview

Source: Internet
Author: User

Chapter 9 editing uitableview

 

 

1. XIB files are typically used to create the view for a View Controller, but they can also be used any time you want to lay out view objects, archive them, and have them loaded at runtime. and you can load XIB file manually with nsbundle.

 

// Load header View

-(Uiview *) headerview

{

If (! _ Headerview)

{

[[Nsbundle mainbundle] loadnibnamed: @ "headerview" Owner: Self options: Nil];

}

Return _ headerview;

}

 

 

2. when a new row was inserted into tableview, the data source also need to be inserted an new object. because the role of a view object is to present model objects to the user, updating views without updating the Model objects is not very useful.

 

3. Difference Between reomveobjectidenticalto: And removeobject ::

 

Removeobject: goes to each object in the array and sends it the message isequal:. A class can implement this method to return YES or NO based on its own determination.

 

Removeobjectidenticalto:, on the other hand, removes an object if and only if it is the exact same object as the one passed in this message.

 

 

4. Note that simply implementing tableview: moverowatindexpath: toindexpath: caused the reordering controls to appear. The model has to implementing the reorder method.

 

// Datasource implements tableview: moverowatindexpath: toindexpath

-(Void) tableview :( uitableview *) tableview moverowatindexpath :( nsindexpath *) sourceindexpath toindexpath :( nsindexpath *) destinationindexpath

{

[[Bnritemstore sharedstore] moveitemfromindex: sourceindexpath. Row toindex: destinationindexpath. Row];

}

 

// Model of array implement

-(Void) moveitemfromindex :( nsinteger) fromindex toindex :( nsinteger) toindex

{

If (fromindex = toindex)

{

Return;

}

Bnritem * Item = self. privateitems [fromindex];

[Self. privateitems removeobjectatindex: fromindex];

[Self. privateitems insertobject: item atindex: toindex];

}

 

 

 

 

 

 

Chapter 9 editing 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.