IOS-tableview learning V2.0

Source: Internet
Author: User

There are two protocols in tableview <protocol>

<Uitableviewdelegate>

<Uitableviewdatasource>

First view <uitableviewdelegate>

The above methods are optional.

// Display Customization

Custom display interface, divided into Will and did

Will and did are also divided into display cells, headview and footview

-(Void) tableview :( uitableview *) tableview willdisplaycell :( uitableviewcell *) cell forrowatindexpath :( nsindexpath *) indexpath;

-(Void) tableview :( uitableview *) tableview willdisplayheaderview :( uiview *) view forsection :( nsinteger) Section ns_available_ios (6_0 );

-(Void) tableview :( uitableview *) tableview willdisplayfooterview :( uiview *) view forsection :( nsinteger) Section ns_available_ios (6_0 );

-(Void) tableview :( uitableview *) tableview didenddisplayingcell :( uitableviewcell *) cell forrowatindexpath :( nsindexpath *) indexpath ns_available_ios (6_0 );

-(Void) tableview :( uitableview *) tableview didenddisplayingheaderview :( uiview *) view forsection :( nsinteger) Section ns_available_ios (6_0 );

-(Void) tableview :( uitableview *) tableview didenddisplayingfooterview :( uiview *) view forsection :( nsinteger) Section ns_available_ios (6_0 );

 

// Variable Height Support

 

-(Cgfloat) tableview :( uitableview *) tableview heightforrowatindexpath :( nsindexpath *) indexpath;

-(Cgfloat) tableview :( uitableview *) tableview heightforheaderinsection :( nsinteger) Section;

-(Cgfloat) tableview :( uitableview *) tableview heightforfooterinsection :( nsinteger) Section;

 

// Section header & footer information. Views are preferred over title shoshould you decide to provide both

 

-(Uiview *) tableview :( uitableview *) tableview viewforheaderinsection :( nsinteger) Section; // custom view for header. will be adjusted to default or specified header height

-(Uiview *) tableview :( uitableview *) tableview viewforfooterinsection :( nsinteger) Section; // custom view for footer. will be adjusted to default or specified footer height

 

// Accessories (disclosures ).

 

-(Uitableviewcellaccessorytype) tableview :( uitableview *) tableview accessorytypeforrowwithindexpath :( nsindexpath *) indexpath ns_deprecated_ios (2_0, 3_0 );

-(Void) tableview :( uitableview *) tableview accessorybuttontappedforrowwithindexpath :( nsindexpath *) indexpath;

 

// Selection

 

//-Tableview: shouldhighlightrowatindexpath: is called when a touch comes down on a row.

// Returning no to that message halts the selection process and does not cause the currently selected row to lose its selected look while the touch is down.

-(Bool) tableview :( uitableview *) tableview shouldhighlightrowatindexpath :( nsindexpath *) indexpath ns_available_ios (6_0 );

-(Void) tableview :( uitableview *) tableview didhighlightrowatindexpath :( nsindexpath *) indexpath ns_available_ios (6_0 );

-(Void) tableview :( uitableview *) tableview didunhighlightrowatindexpath :( nsindexpath *) indexpath ns_available_ios (6_0 );

 

// Called before the user changes the selection. Return a new indexpath, or nil, to change the proposed selection.

-(Nsindexpath *) tableview :( uitableview *) tableview willselectrowatindexpath :( nsindexpath *) indexpath;

-(Nsindexpath *) tableview :( uitableview *) tableview willdeselectrowatindexpath :( nsindexpath *) indexpath ns_available_ios (3_0 );

// Called after the user changes the selection.

-(Void) tableview :( uitableview *) tableview didselectrowatindexpath :( nsindexpath *) indexpath;

-(Void) tableview :( uitableview *) tableview diddeselectrowatindexpath :( nsindexpath *) indexpath ns_available_ios (3_0 );

 

// Editing

 

// Allows mizmization of the editingstyle for a special cell located at 'indexpath'. If not implemented, all editable cells will have uitableviewcelleditingstyledelete set for them when the table has editing property set to yes.

-(Uitableviewcelleditingstyle) tableview :( uitableview *) tableview editingstyleforrowatindexpath :( nsindexpath *) indexpath;

-(Nsstring *) tableview :( uitableview *) tableview titlefordeleteconfirmationbuttonforrowatindexpath :( nsindexpath *) indexpath ns_available_ios (3_0 );

 

// Controls whether the background is indented while editing. If not implemented, the default is yes. This is unrelated to the indentation level below. This method only applies to grouped style table views.

-(Bool) tableview :( uitableview *) tableview shouldindentwhileeditingrowatindexpath :( nsindexpath *) indexpath;

 

// The willbegin/didend methods are called whenever the 'editing' property is automatically changed by the table (allowing insert/delete/move). This is done by a swipe activating a single row

-(Void) tableview :( uitableview *) tableview willbegineditingrowatindexpath :( nsindexpath *) indexpath;

-(Void) tableview :( uitableview *) tableview didendeditingrowatindexpath :( nsindexpath *) indexpath;

 

// Moving/reordering

 

// Allows customization of the target row for a special row as it is being moved/reordered

-(Nsindexpath *) tableview :( uitableview *) tableview targetindexpathformovefromrowatindexpath :( nsindexpath *) sourceindexpath toproposedindexpath :( nsindexpath *) proposeddestinationindexpath;

 

// Indentation

 

-(Nsinteger) tableview :( uitableview *) tableview indentationlevelforrowatindexpath :( nsindexpath *) indexpath; // return 'dest' of row for hierarchies

 

// Copy/paste. All three methods must be implemented by the delegate.

 

-(Bool) tableview :( uitableview *) tableview shouldshowmenuforrowatindexpath :( nsindexpath *) indexpath ns_available_ios (5_0 );

-(Bool) tableview :( uitableview *) tableview can1_maction :( SEL) Action forrowatindexpath :( nsindexpath *) indexpath withsender :( ID) sender ns_available_ios (5_0 );

-(Void) tableview :( uitableview *) tableview into maction :( SEL) Action forrowatindexpath :( nsindexpath *) indexpath withsender :( ID) sender ns_available_ios (5_0 );

 

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.