iOS development Project-54 "Setup" interface construction
First, to achieve
Create a new settings controller and jump to the "my" Controller navigation bar when the "Settings" button is clicked.
1. Handling of the "set button" in the navigation bar in the "Me" controller
1 //2 //YYPROFILEVIEWCONTROLLER.M3 //4 5 #import "YYProfileViewController.h"6 #import "YYCommonGroup.h"7 #import "YYCommonItem.h"8 #import "YYCommonCell.h"9 #import "YYCommonArrowItem.h"Ten #import "YYCommonSwitchItem.h" One #import "YYCommonLabelItem.h" #import "YYSettingViewController.h" - - @interfaceYyprofileviewcontroller () the - @end - - @implementationYyprofileviewcontroller + -- (void) Viewdidload + { A [Super Viewdidload]; at - //Initializing model data - [self setupgroups]; - - self.navigationitem.rightbarbuttonitem=[[uibarbuttonitem alloc]initwithtitle:@ " settings " Style:uibarbuttonitemstyledone target:self Action: @selector (setting)]; - } in-(void) Setting - { to yysettingviewcontroller *vc=[[Yysettingviewcontroller alloc]init]; + [Self.navigationcontroller PUSHVIEWCONTROLLER:VC animated:yes]; -}
2. Handling of the "Settings" controller
It can be found that the interface setting of the controller is similar to the "I" interface, so it can be considered that the controller also inherits from the Yycommonviewcontroller and makes the appropriate adjustments.
The complete code is designed as follows:
YYSETTINGVIEWCONTROLLER.M file
1 //2 //YYSETTINGVIEWCONTROLLER.M3 //4 5 #import "YYSettingViewController.h"6 #import "YYCommonGroup.h"7 #import "YYCommonItem.h"8 #import "YYCommonArrowItem.h"9 #import "YYCommonSwitchItem.h"Ten #import "YYCommonLabelItem.h" One A @interfaceYysettingviewcontroller () - - @end the - @implementationYysettingviewcontroller - - +- (void) Viewdidload - { + [Super Viewdidload]; Aself.title=@"Set"; at [self setupgroups]; - } - --(void) setupgroups - { - //Group No. 0 in [self setupGroup0]; - //Group 1th to [self setupGroup1]; + [self setupGroup2]; - [self setupGroup3]; the [self setupfooter]; * } $ Panax Notoginseng-(void) SetupGroup0 - { the //1. Create a group +Yycommongroup *group=[Yycommongroup Group]; A [self.groups Addobject:group]; the + //3. Set up data for all rows in the group -Yycommonarrowitem *mag=[yycommonarrowitem Itemwithtitle:@"Account Management"]; $group.items=@[mag]; $ - } - the-(void) SetupGroup1 - {Wuyi //1. Create a group theYycommongroup *group=[Yycommongroup Group]; - [self.groups Addobject:group]; Wu - //3. Set up data for all rows in the group AboutYycommonarrowitem *main=[yycommonarrowitem Itemwithtitle:@"subject, Background"]; $group.items=@[main]; - } - --(void) setupGroup2 A { + //1. Create a group theYycommongroup *group=[Yycommongroup Group]; - [self.groups Addobject:group]; $ the //3. Set up data for all rows in the group theYycommonarrowitem *notice=[yycommonarrowitem Itemwithtitle:@"Notifications and Reminders"]; theYycommonarrowitem *commonsettings=[yycommonarrowitem Itemwithtitle:@"Common Settings"]; theYycommonarrowitem *privacyandsecurity=[yycommonarrowitem Itemwithtitle:@"Privacy and Security"]; -group.items=@[notice,commonsettings,privacyandsecurity]; in } the the-(void) SetupGroup3 About { the //1. Create a group theYycommongroup *group=[Yycommongroup Group]; the [self.groups Addobject:group]; + - //3. Set up data for all rows in the group theYycommonarrowitem *feedback=[yycommonarrowitem Itemwithtitle:@"View Feedback"];BayiYycommonarrowitem *about=[yycommonarrowitem Itemwithtitle:@"about the"]; thegroup.items=@[feedback,about]; the } - --(void) Setupfooter the { the theUIButton *logout=[[UIButton alloc]init]; the[Logout Settitle:@"Exit Current Account"Forstate:uicontrolstatenormal]; -[Logout Settitlecolor:yycolor (255, -, -) Forstate:uicontrolstatenormal]; the[Logout setbackgroundimage:[uiimage Resizedimage:@"Common_card_background"] forstate:uicontrolstatenormal]; the[Logout setbackgroundimage:[uiimage Resizedimage:@"common_card_background_highlighted"] forstate:uicontrolstatehighlighted]; the 94 //Set Dimensions thelogout.height= *; the theself.tableview.tablefooterview=logout;98 About } - @end
Display effect:
Note : To exit the current account this cell is not the same as the normal cell, and you need to be aware of the difference.
First, you can create a new subclass, inherit from Yycommonitem, judge the type in the custom cell, and if it is the type of the subclass, set the midpoint of the LabelText X to the midpoint of the entire cell. But there is a big problem with this approach, which involves the recycling of cells, which is troublesome. This practice is not recommended.
The second and easiest way to do this is to create a button and set the button to the entire TableView Footerview.
Note: Headerview and Footerview do not need to be set to width, which is the width of the entire cell by default.
3. Set the cell header and footer
The head and tail can be set in the General class Yycommonviewcontroller controller
1-(NSString *) TableView: (UITableView *) TableView titleforfooterinsection: (nsinteger) section2 {3Yycommongroup *group=Self.groups[section];4 returnGroup.grougfooter;5 6 }7 8-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: (nsinteger) section9 {TenYycommongroup *group=Self.groups[section]; One returnGroup.groupheader; A}