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