19. My Pages-Main page
Just finished home recommended secondary housing This is a very troublesome thing, to some easy bar. First do the backstage my page to put.
The first version does not involve the customer's sign-up operation, so it is relatively simple. It is mainly used in the tableview of the system itself.
Also because there is no customer login and other operations, so some of the view records are saved locally. If you uninstall the app and then reinstall it is empty.
1.. h File Creation variables
#import <UIKit/UIKit.h>@interface**Zoomimageview; @end
2. TableView of M files
(1) Define data variables and load delegate
@interface Rdmytableviewcontroller () <UITableViewDataSource,UITableViewDelegate>{ *arrlist;} @end
(2) TableView initialization
//Initialize My informationArrlist =@[@[[nsmutabledictionary dictionarywithobjectsandkeys:@"The listings I've seen",@"title",@"icon_viewhistory",@"Image",@"1",@"Isshow", nil], [nsmutabledictionary Dictionarywithobjectsandkeys:@"I am concerned about the new houses",@"title",@"Icon_focus_house",@"Image",@"1",@"Isshow", nil], [nsmutabledictionary Dictionarywithobjectsandkeys:@"I am concerned about the housing/rental",@"title",@"Icon_focus_house",@"Image",@"1",@"Isshow", nil]],@[[nsmutabledictionary dictionarywithobjectsandkeys:@"Home Purchase Calculator",@"title",@"Icon_jisuanqi",@"Image",@"1",@"Isshow", nil]],@[[nsmutabledictionary dictionarywithobjectsandkeys:@"Set",@"title",@"Icon_setup",@"Image",@"1",@"Isshow", Nil],]; //Initialize TableViewSelf.tableview = [[UITableView alloc] Initwithframe:cgrectmake (0, self.navigationcontroller.navigationbar.frame.size.height+ -, Screen_width, Screen_height) style:uitableviewstylegrouped]; Self.tableview.Delegate=Self ; Self.tableView.dataSource=Self ; Self.tableView.contentInset= Uiedgeinsetsmake (Bgimageheight,0,0,0); Self.tableView.rowHeight=46.0f; [Self.view AddSubview:self.tableView]; //define a multiplexed cell[Self.tableview Registerclass:[setuplistcellclass] Forcellreuseidentifier:@"Setuplistcell"];
(3) TableView Method of Delegation
-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView {returnArrlist.count;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {Nsarray*arrsection =Arrlist[section]; returnArrsection.count;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {UITableViewCell*cell = [TableView dequeuereusablecellwithidentifier:@"Setuplistcell"Forindexpath:indexpath]; Nsarray*arrsection =Arrlist[indexpath.section]; Nsdictionary*dictdata =Arrsection[indexpath.row]; Cell.textLabel.text= [Dictdata Objectforkey:@"title"]; Cell.imageView.image=[uiimage imagenamed:[dictdata Objectforkey:@"Image"]]; Cell.accessorytype=Uitableviewcellaccessorydisclosureindicator; returncell;}-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) section{return 0.1f;}-(CGFloat) TableView: (UITableView *) TableView heightforfooterinsection: (nsinteger) section{return 10.0f;}
(4) TableView cell Click event Part function to be implemented
-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{[TableView Deselectrowatindexpath:indexpath Animated:no]; if(indexpath.section==0) { if(indexpath.row==0) { #warningPending code The listings I've seen//The listings I've seen}Else if(indexpath.row==1) { #warningPending code my concern about the new house//I am concerned about the new houses}Else if(indexpath.row==2) { #warningPending code I care about the secondhand//I am concerned about the secondary } }Else if(indexpath.section==1) { if(indexpath.row==0) { #warningPending Code Mortgage Calculator//Mortgage Calculator } }Else if(indexpath.section==2) { if(indexpath.row==0) { //SetRdsetupviewcontroller *SETUPVC =[[Rdsetupviewcontroller alloc]init]; Self.navigationItem.backBarButtonItem=[[uibarbuttonitem Alloc] Initwithtitle:@"return"style:uibarbuttonitemstyledone Target:nil Action:nil]; [Self.navigationcontroller PUSHVIEWCONTROLLER:SETUPVC Animated:no]; } }}
(5) UITableViewCell did not use the default system cell, slightly changed, the name is Setuplistcell
#import "SetupListCell.h"@implementationSetuplistcell- (void) awakefromnib {//Initialization Code}//overriding the Layoutsubviews method to achieve picture size effects-(void) layoutsubviews{[Super Layoutsubviews]; Self.imageView.frame=cgrectmake ( the, (self.frame.size.height- -)/2, -, -); Self.imageView.contentMode=Uiviewcontentmodescaleaspectfit; CGRect Tempframe=Self.textLabel.frame; Tempframe.origin.x= -; Self.textLabel.frame=Tempframe; Self.textLabel.font=[uifont systemfontofsize: -]; Self.separatorinset=uiedgeinsetsmake (0, -,0,0);}- (void) setselected: (BOOL) selected animated: (bool) animated {[Super setselected:selected animated:animated]; //Configure The View for the selected state}@end
3. The. m file is pulled into a larger image.
(1) Defining macro variables
#define Bgimageheight 160.0f
(2) Initialize image view
// Initialize zoom picture Self.zoomimageview = [[Uiimageview alloc]initwithframe:cgrectmake (0,-bgimageheight, Screen_width, Bgimageheight)]; = [UIImage imagenamed:@ "main_my_bg"]; = Uiviewcontentmodescaleaspectfill; [Self.tableview Addsubview:_zoomimageview];
(3) Scroll trigger method
#pragma Mark ScrollView scrolling event-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{ // Zoom the picture when scrolling CGFloat y = self.tableview.contentoffset.y; if (y<=bgimageheight) { CGRect frame=_zoomimageview.frame; = y; =-y; = frame; } }
Look at the effect.
Learn to make iOS program sixth day: My page-Main page (19)