ios-Ordering System

Source: Internet
Author: User

////VIEWCONTROLLER.M//Order ordering System////Created by Yaguangzhu on 15/8/27.//Copyright (c) 2015 Yaguangzhu. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () <UIPickerViewDataSource,UIPickerViewDelegate>@property (nonatomic,strong) Nsarray*Foods, @property (weak, nonatomic) Iboutlet UILabel*Fruitlbl, @property (weak, nonatomic) Iboutlet UILabel*Meatlbl, @property (weak, nonatomic) Iboutlet UILabel*Waterlbl;-(ibaction) random; @property (weak, nonatomic) Iboutlet Uipickerview*Pickerview;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.         for(intComponent =0; Component < Self.foods.count; Component + +) {[Self Pickerview:nil didselectrow:0Incomponent:component]; }}-(Nsarray *) foods{if(_foods = =Nil) {_foods= [Nsarray arraywithcontentsoffile:[[nsbundle mainbundle] Pathforresource:@"Foods"OfType:@"plist"]]; }        return_foods;}-(Nsinteger) Numberofcomponentsinpickerview: (Uipickerview *) pickerview{returnSelf.foods.count;}-(Nsinteger) Pickerview: (Uipickerview *) Pickerview numberofrowsincomponent: (nsinteger) component{//[Self.foods objectatindex:component].        return[Self.foods[component] count];}-(NSString *) Pickerview: (Uipickerview *) Pickerview Titleforrow: (nsinteger) Row forcomponent: (nsinteger) component{returnSelf.foods[component][row]; //return @ "haha";}- (void) Pickerview: (Uipickerview *) Pickerview Didselectrow: (nsinteger) Row incomponent: (nsinteger) component{if(Component = =0) {Self.fruitLbl.text=Self.foods[component][row]; }Else if(Component = =1) {Self.meatLbl.text=Self.foods[component][row]; }Else{Self.waterLbl.text=Self.foods[component][row]; }        }- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}-(ibaction) Random { for(intComponent =0; Component < Self.foods.count; Component + +) {                //the line number before removing        intOldrow =[Self.pickerview selectedrowincomponent:component]; //make the current line number equal to the previous line number        introw =Oldrow; intCount =[Self.foods[component] count];  while(Row = =Oldrow) {            //Random line numberrow = Arc4random ()%count; }                //Pickerview Select a row of a column by itself[Self.pickerview selectrow:row incomponent:component Animated:yes]; //assign a value to the label below[self Pickerview:nil didselectrow:row incomponent:component]; }}@end

ios-Ordering System

Related Article

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: 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.