IOS Tabelview Group, Xib, cell--in Lan Yi Education study notes

Source: Internet
Author: User

Tabelview Group. Table header, footer

Delete VC Build TVC

The group interface return 2 points 2 groups, in the control row plus judgment if section== 1 return10 (at this time 012 0123456789)Select TV in SB to change the style to grouped at this time there is an intervalControls group headers and tails. Has a string

-(NSString *) TableView: (UITableView *) TableView titleforheaderinsection: (Nsinteger) section{

return @ "I am the head";

}

-(NSString *) TableView: (UITableView *) TableView titleforfooterinsection: (Nsinteger) section{

return @ "I am the tail";

}

if the TV display line is removed, select TV has a separator change to none or change the color of the lines Add Headview (top) display effect: You can scroll up and down the page (micro-blog) in SB to drag into the view to the top of the cell, you can adjust the height, you can drag into the label, Uiimageview, TextView and so on. At this time a scroll with scrolling, the above is not moving the VC if it is the code control Headview content, then drag the control to TVC and then control its display Footview is the view dragged into the middle, or below, ——————————static cell (contents are immutable, such as settings)Use the words to comment out the code in SB build TVC Click on the TV right option to select the content number is the group can drag various controls on topHowever, the number of lines and the code to display the content is turned offBut can add click event, Method: Tabelview Didseletctrow ... {} —————————— Create Xib delete sb, set option delete option for main interface. In Appdelegate. In the first method in M,

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {

Self.window = [[UIWindow alloc]initwithframe:[uiscreen mainscreen].bounds];

Self.window.rootViewController = VC; (This is the newly created page)

[Self.window makekeyandvisible];

return YES;

}

Delete the VC and create an inherited UITVC TVC and create a hook for xib. Back to Appdelegate.  m just adding tableviewcontroller *VC = [[Viewcontroller alloc]initwithnibname:@ "Tableviewcontroller" Bundle:nil] in the method. ———— can also create a VC, and Hook Xib in app,m associated VC, in VC. XLB creates the control, and associates it, and associates it with the VC. M set jump page: 1, declare TVC, enter the Click event Set TVC*VC =. Set a jump. Xib used in the page ————————————————Xib can also be used as a controlsuch as a combination of forms to make a wait interface: loading 、、、 new VC and associated Hook xib, enter the Xib interface, adjust the page size, the right side of the battery removed, dragged into the chrysanthemum, tabel. The controls written loading at this time xib cannot be dragged into m, only H. then return to VC. M in association Loadingview set up custom interface for creating Xib in Viewdidload

Loadingview *LV = [[[NSBundle mainbundle]loadnibnamed:@ "Loadingview" owner:self Options:nil] lastObject];

Lv.center = Self.view.center; set to Middle

[Self.view ADDSUBVIEW:LV];

But at this point xib is an array, where the Lastobject is the last,-———————— custom cel L There are three ways: 1, Pure code (display layout is not fixed) 2, through SB (the simplest: fixed, no longer) 3, through the Xib (display fixed but involves multiplexing)if it's pure code, just putCell Delete  Create a cell that is purely code-createdDelete VC Establish TVC Association TVC remove the cell yourself create an inheritance Uitabelviewcell in the TVC Declaration import cell to implement the left image to the right of the text, at this time there is no cell in SB, so the display content will be changed into

Mytableviewcell *cell = [TableView dequeuereusablecellwithidentifier:@ "Cell"];

And judge if the cell is not present, then cell = [[Mytableviewcell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:@ "cell]; Once the control is created, it is entered into the MYTVC. In M, this is the time to rewrite the initialization method. ———— Enter init--and prompt for fourth after selecting and re-replacing into Initwithstylebecause later TVC.M needed to use the properties of the control, it was set to a property 

-(Instancetype) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) reuseidentifier

{

self = [super Initwithstyle:style reuseidentifier:reuseidentifier];

if (self) {

Write the various controls you want to add

SELF.IV = [[Uiimageview alloc]initwithframe:cgrectmake (280, 0, 40, 40)];

Self.iv.backgroundColor = [Uicolor Bluecolor];

[Self.contentview ADDSUBVIEW:SELF.IV];

}

return self;

}

This returns TVC. Set 10 rows in m so that each row has its own definition of content (just IV in MYTVC. H declares its own property andIt is important to note that ImageView cannot be named, so it's self) in TVC, declare cell. iv Image = @ ""; ———————————————————————— 2 Create a custom cell in SB: Select cell in SB to create a class of MYTVC, and associate Cell,cell to drag and drop the desired effect at this time, if the contents (label) Changes associated with the code (such as the number increment), then the label link MYTVC. H to create at this time, go to TVC. M mediumif it is pure code creation, is a parameter, if SB is created is two parameters this is SB creation. So  Add a cell.mylabel.text =. %d.in. Row:, you can now display progressive effect —————————— Xib custom cell in SB Drag TV come in, and wired two options, add two in the VC, Tvdatasource and delegate into the first Protocol, must implement the method, Copy to the outside, a line number of a content, Retun 10 line at this time create an integrated UIVC VC, and Hook xib in the Xib drag control, back to the VC. The MYTVC is associated with the display content, and the cell is created. Mytableviewcell *cell = [TableView dequeuereusablecellwithidentifier:@ "Cell"]; Judging if the cell is not worth, then

if (!cell) {

cell = [[[NSBundle mainbundle]loadnibnamed:@ "Mytableviewcell" owner:self Options:nil]lastobject];

}

and return cell;    But to identify the cell in the Xib cell  And the size of the dragged interface in the xib is not affected in the display, so enter the method to control the line height in the back VC

-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{

return 130;

}

  

IOS Tabelview Group, Xib, cell--in Lan Yi Education study notes

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.