iOS cell Common Properties

Source: Internet
Author: User

1, set the Accessoryview of UITableViewCell

Sometimes we need to set some of the cell's styles, for example,

This is what sets the cell's accessory property, and if we want to show switch on it, we can use the following code,

Cell.accessoryview = _modelswitch;

This is to use a Uiswitch object _modelswitch assignment to Cell.accessoryview, of course, you can use any UIView sub-class control such as Uilabel, UIButton ... object to assign a value to the Cell.accessoryview so that the interface shows the effect you want.

2, set the Accessorytype of UITableViewCell

If you want the cell to display a light gray arrow, you can use Accessorytype to achieve the goal, the code is as follows,

Cell.accessorytype = Uitableviewcellaccessorydisclosureindicator;

This sets the type of the arrow, we can set a number of types, Apple defines the enumeration type as follows,

typedef ns_enum (Nsinteger, Uitableviewcellaccessorytype) {

Uitableviewcellaccessorynone,//Do not show any Accessoryview

Uitableviewcellaccessorydisclosureindicator,//light gray arrow icon

Uitableviewcellaccessorydetaildisclosurebutton,//button showing details

Uitableviewcellaccessorycheckmark,//Is the hook shape you hook up when you test

Uitableviewcellaccessorydetailbutton Ns_enum_available_ios (7_0)//

};

Readers can try each one to find the effect they want. If the above effect is not satisfactory, then you can only customize the cell, and then put the Uiimageview on the cell, and paste the image of their own design.

3, set UITableViewCell the click Style Selectionstyle,

Sometimes we need to click the cell when the corresponding cell background to deepen the effect, sometimes we do not need, this time can use the following statement to achieve,

Settingcell.selectionstyle = Uitableviewcellselectionstylenone

View the enumeration types in the document as follows,

typedef ns_enum (Nsinteger, Uitableviewcellselectionstyle) {

Uitableviewcellselectionstylenone,

Uitableviewcellselectionstyleblue,

Uitableviewcellselectionstylegray,

Uitableviewcellselectionstyledefault Ns_enum_available_ios (7_0)

};

Readers can try each one, here is just a shot, no longer repeat.

4. When you return to the previous page, the cell removes the click Effect.

When we click on Cell,push to go to the next page and then return to the previous page, we find that the cell has a deeper effect on the background, as shown in

To get rid of this effect, just add the following code to the-(void) Tableview...didselect

#pragma Mark-uitableviewdatasource method

-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath

{

//....

[TableView Deselectrowatindexpath:indexpath Animated:yes];

}

This way, when you return to the previous page, the previously selected cell does not have the effect of a background burn, as shown in

iOS cell Common Properties

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.