Ios-with Xib and UI table View Controller's group purchase site

Source: Internet
Author: User
Tags uikit

First, the footage is the same as the photo and plist file, and then the dictionary model.

The disadvantage of the UI table View controller is that it does not have the flexibility to control the size and layout of pictures

So create a new Xib file, and then create a new class with the same name Xib inherit the controls inside this class to drag lines into the class

////Tg.h//Group Purchase Network////Created by Yaguangzhu on 15/8/18.//Copyright (c) 2015 Yaguangzhu. All rights reserved.//#import<Foundation/Foundation.h>@interfaceTg:nsobject@property (nonatomic,copy) NSString*title: @property (nonatomic,copy) NSString*icon; @property (nonatomic,copy) NSString*Price ; @property (nonatomic,copy) NSString*Buycount;-(Instancetype) Initwithdict: (Nsdictionary *) dict;+ (Instancetype) tgwithdict: (Nsdictionary *) dict;+ (Nsarray *) TGS;@end
////TG.M//Group Purchase Network////Created by Yaguangzhu on 15/8/18.//Copyright (c) 2015 Yaguangzhu. All rights reserved.//#import "Tg.h"@implementationTg-(Instancetype) Initwithdict: (Nsdictionary *) dict{ Self=[Super Init]; if(self) {[self setvaluesforkeyswithdictionary:dict]; }    returnSelf ;}+ (Instancetype) tgwithdict: (Nsdictionary *) dict{return[Self alloc] initwithdict:dict];}+ (Nsarray *) tgs{Nsarray*array = [Nsarray arraywithcontentsoffile:[[nsbundle mainbundle] Pathforresource:@"tgs.plist"Oftype:nil]]; Nsmutablearray*arraym =[Nsmutablearray array];  for(Nsdictionary *dictinchArray)    {[Arraym addobject:[self tgwithdict:dict]]; }        returnArraym;}@end
////VIEWCONTROLLER.M//Group Purchase Network////Created by Yaguangzhu on 15/8/18.//Copyright (c) 2015 Yaguangzhu. All rights reserved.//#import "ViewController.h"#import "Tg.h"#import "TgCell.h"@interfaceViewcontroller () @property (nonatomic,strong) Nsarray*TGS;@end@implementationViewcontroller-(Nsarray *) tgs{if(_tgs = =Nil) {_TGS=[Tg TGS]; }    return_tgs;}- (void) viewdidload {[Super viewdidload]; Self.tableView.rowHeight= the; //adjust the margin to implement the interference of the status bar//adjust the margins to make the table view stand out of the status barSelf.tableView.contentInset = Uiedgeinsetsmake ( -,0,0,0); //additional setup after loading the view, typically from a nib.}//Hide the status bar//-(BOOL) Prefersstatusbarhidden//{//return YES;//}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{returnSelf.tgs.count;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{StaticNSString *id =@"Cell"; Tgcell*CELL1 =[TableView Dequeuereusableheaderfooterviewwithidentifier:id]; if(Cell1 = =Nil) {        //cell = [[UITableViewCell alloc] Initwithstyle:uitableviewcellstylesubtitle Reuseidentifier:id]; //load a custom view from inside the XibCELL1 = [[[NSBundle Mainbundle] loadnibnamed:@"Tgcell"Owner:nil Options:nil] lastobject]; } Tg*TG =Self.tgs[indexpath.row];//cell.textLabel.text = tg.title;//cell.imageView.image = [UIImage ImageNamed:tg.icon];//Cell.detailTextLabel.text = [NSString stringwithformat:@ "$%@ has been purchased by%@ people", Tg.price,tg.buycount];Cell1.titleLabel.text=Tg.title; Cell1.imageView.image=[UIImage ImageNamed:tg.icon]; Cell1.priceLabel.text=Tg.price; Cell1.buyCountLabel.text=Tg.buycount; returncell1; }- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}@end
////TgCell.h//Group Purchase Network////Created by Yaguangzhu on 15/8/18.//Copyright (c) 2015 Yaguangzhu. All rights reserved.//#import<UIKit/UIKit.h>@interfaceTgcell:uitableviewcell@property (Weak, nonatomic) Iboutlet Uiimageview*IconView, @property (weak, nonatomic) Iboutlet UILabel*Titlelabel, @property (weak, nonatomic) Iboutlet UILabel*Buycountlabel, @property (weak, nonatomic) Iboutlet UILabel*Pricelabel;@end
////TGCELL.M//Group Purchase Network////Created by Yaguangzhu on 15/8/18.//Copyright (c) 2015 Yaguangzhu. All rights reserved.//#import "TgCell.h"@implementationTgcell- (void) awakefromnib {//Initialization Code}- (void) setselected: (BOOL) selected animated: (bool) animated {[Super setselected:selected animated:animated]; //Configure The View for the selected state}@end

Ios-with Xib and UI table View Controller's group purchase site

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.