IOS Shopping-Personal Center interface

Source: Internet
Author: User

The last QQ interface true unintentionally inserted willow, unexpectedly a novice's ordinary interface can first page recommendation, in this thank those CSDN worker to novice support, thank SOLEDADZZ Special recommendation;

The following interface is also the teacher to exercise my topic is mainly to let me familiar with the use of table; I want to try to use MVC, as far as possible to achieve the interface and data separation, but a level did not reach, do not know that the interface is not a real separation, how much worse, if you see the problem, please leave a word, Help a hand, thank you!

File original code to the end of the link to download, thank you, need a point to earn points outside the block, if no points can leave a message, or leave QQ I send to you.

Because I PS technology reasons, not able to the bottom of the four small pictures out, resulting in the bottom of the Tabbar no pictures, we can add their own.

First, the following file:


Because recently see can code specifications of some things, just start with, I think the name of what to do as far as possible, see the name to know is why.

In the personalcentretable file is placed in the middle of the interface table and cell below the Personalcentreheadview is the interface head is the avatar, the blue background part

The Personalcentreview is the whole interface part;

There is no need for other places to introduce;

First implemented in the Appdelegate Tabbar

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (    Nsdictionary *) launchoptions{//Override point for customization after application launch.    _window = [[UIWindow alloc]initwithframe:[[uiscreen Mainscreen]bounds]];    Uiviewcontroller *VC1 = [[Uiviewcontroller alloc]init];    Vc1.view.backgroundColor = [Uicolor Redcolor];    Vc1.title = @ "Home";    Uiviewcontroller *VC2 = [[Uiviewcontroller alloc]init];    Vc2.view.backgroundColor = [Uicolor Graycolor];    Vc2.title = @ "Merchant";    Uiviewcontroller *VC3 = [[Uiviewcontroller alloc]init];    Vc3.view.backgroundColor = [Uicolor Greencolor];    Vc3.title = @ "Shopping cart";    Viewcontroller *vc4 = [[Viewcontroller alloc]init];    Vc4.title = @ "Personal Center";    Nsarray *ARRAYVC = @[vc1,vc2,vc3,vc4];    Self.tabbarc = [[Uitabbarcontroller alloc]init];    Self.tabBarC.viewControllers = ARRAYVC;    _window.rootviewcontroller = Self.tabbarc;    [_window makekeyandvisible]; return YES;} 
To construct the data:

Nsdictionary *dictionary = @{@ "personal_protrait": @ "Icon.png"                                 @ "Personal_name": @ "Cedar" @                                 "Personal_ Integral ": @" @ "@" @ "                                 Personal_welfare": @ "@"                                 @ "personal_table": @{@ "Pending payment order": @ "@",                                                     @ "Pending order": @ "5",                                                     @ "Shipped order": @ "4"}                                 ;


Let's see the cell first.

@property (Nonatomic,strong) UILabel *namelabel; @property (Nonatomic,strong) UILabel *numberlabel; @property ( Nonatomic,strong) Uiimageview *rightimageview;

A name, a number, an icon can be seen against the map to understand;

-(ID) Initwithname: (NSString *) name Number: (NSString *) number rightimage: (UIImage *) image{self    = [super init];    if (self) {        //Set text        _namelabel = [[UILabel alloc]initwithframe:cgrectmake ()];        _namelabel.text =name;        [Self Addsubview:_namelabel];                Set the identification number        _numberlabel = [[UILabel alloc]initwithframe:cgrectmake (+,-)];        _numberlabel.text = number;        _numberlabel.textalignment = 1;        _numberlabel.textcolor = [Uicolor redcolor];        [Self Addsubview:_numberlabel];                Set Right picture        _rightimageview = [[Uiimageview alloc]initwithframe:cgrectmake (290, ten, +)];        _rightimageview.image = image;        [Self Addsubview:_rightimageview];            }    return self;}

Next is table.

@interface personalcentretable:uitableview<uitableviewdatasource,uitableviewdelegate> @property (nonatomic, copy) nsdictionary *datadictionary;   Data passed-(ID) initwithdictionary: (Nsdictionary *) dictionary; @end


When implementing table I want to have 4 sections and the rows are different, and the contents of each line are different, so

-(uitableviewcell *) TableView: (uitableview *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath

How to write, to a if to determine which section and then determine which line? So hard, so I thought of the array. A veteran should naturally think, but as a novice can use or quite happy;

Tablearray = @[@[@ "Pending payment order",                     @ "order to be shipped",                     @ "shipped order"],                   @[@ "completed order",                   @[@ "after-sales service"],                   @[@ "settings"];

This array is much simpler to combine with the following code.

-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{    Personalcentretablecell *cell;        if (indexpath.section = = 0) {        nsstring *name = [(Nsarray *) [Tablearray objectAtIndex:indexPath.section]                          ObjectAtIndex:indexPath.row];        cell = [[Personalcentretablecell alloc]               initwithname:name               number:[_datadictionary Objectforkey:name]               Rightimage:[uiimage imagenamed:@ "Rightimage.png"];    }    else {        cell = [[Personalcentretablecell alloc]               initwithname:[(Nsarray *) [Tablearray Objectatindex: Indexpath.section]                             ObjectAtIndex:indexPath.row]               number:@ ""               rightimage:[uiimage imagenamed:@ " Rightimage.png "];    }    return cell;}

-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{    return section = = 0? 3:1;    Return ((Nsarray *) [_dataarray objectatindex:section]). Count;}

What I want to say here is that we should use more. : Write less if, should be considered first? : So our code is more tidy;

Speaking of these small parts, let's take a look at the whole part of it Personalcentreview;

<span style= "FONT-SIZE:12PX;" > @interface personalcentreview:uiview@property (nonatomic,strong) UILabel *titlelabel;//title @property (nonatomic, Strong) Personalcentreheadview *personalcentreheadview;//Head  Profile part @property (Nonatomic,strong) Personalcentretable *personalcentretable;//Table Section @property (nonatomic,copy) nsdictionary *datadictionary;//data-(ID) Initwithdictionary: (nsdictionary *) dictionary; @end </span>

-(ID) initwithdictionary: (Nsdictionary *) dictionary{self = [super init];                if (self) {_datadictionary = dictionary;                Self.frame = CGRectMake (0, 0, 320, 480);                Self.backgroundcolor = [Uicolor colorwithred:238/255.0 green:238/255.0 blue:238/255.0 alpha:1];        Set title _titlelabel = [[UILabel alloc]initwithframe:cgrectmake (0, 30, 280, 20)];        _titlelabel.text = @ "Personal Center";        _titlelabel.textalignment = 1;//Center//_titlelabel.textcolor = [Uicolor Whitecolor];                [Self Addsubview:_titlelabel]; Set Avatar section _personalcentreheadview = [[Personalcentreheadview alloc]initwithportrait:[dictionary objectForKey:@] Perso Nal_image "] name:[dictionary objectforkey:@" PE Rsonal_name "] integral:[dictionary Objectforkey: @                    "Personal_integral"]                                                      Welfare:[dictionary objectforkey:@ "Personal_welfare"];                [Self addsubview:_personalcentreheadview]; Set table _personalcentretable = [[personalcentretable alloc]initwithdictionary:[dictionary objectForKey:@] Personal_ta        ble "]);                    [Self addsubview:_personalcentretable]; } return self;}

Source: http://download.csdn.net/detail/u010123208/7805865

Again, these things are for our novice to see, perhaps can help you, because I also want to learn a complete example to practice a practiced hand.

The great gods, the advice, we hope you will stay. "A simple interface, and also the nerve to say ... "In that case we don't want to see it, and I don't believe that you will be stronger than us in two years."


IOS Shopping-Personal Center interface

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.