Lan Yi iOS learning TableCell recipe Exercises

Source: Internet
Author: User

Today Liu Guobin teacher told how to get the text through the path, then parse the text content, finally displayed to the page, using the time of the day to teach you how to use the Xib type of graphical editing custom cell to achieve the cell standard we want. Use the recipe demo how to write, and how to get pictures on the Internet.

If you request data from the Internet, you need to select Open as in the Info.plist configuration file and select Soure code to add a piece

NSData *data=[nsdata Datawithcontentsofurl:[nsurl URLWithString:menu.image];

Override the SetMenu method, where the menu property is the object created by the menu class. The menu class has its own six properties, so you can point it out on the right side of the equal sign, the equal sign to the left is the cell itself six properties, so in the main function to assign a custom cell's menu property, it will automatically call its own set method/This program in the main function to assign a value to the Menu property, Because there are only six properties of the NSString type in the menu class, the assignment is to pass the contents of the array, which is an array of previously prepared strings

-(void) SetMenu: (Menu *) menu{

_menu=menu;

Self.nametable.text=menu.name;

SELF.TAGTEXT.TEXT=MENU.TAGP;

Self.introducettxt.text=menu.introduce;

Self.materioltext.text=menu.materiol;

self.burdentext.text=menu.burdening;

If you request data from the Internet, you need to select Open as in the Info.plist configuration file and select Soure code to add a piece

NSData *data=[nsdata Datawithcontentsofurl:[nsurl URLWithString:menu.image];

Self.imagetable.image=[uiimage Imagewithdata:data];

}

Get text content

Self.imagetable.image=[uiimage Imagewithdata:data];

NSString *path=[[nsbundle mainbundle]pathforresource:@ "recipe text" oftype:@ ""];

NSString *strings=[nsstring Stringwithcontentsoffile:path encoding:nsutf8stringencoding Error:nil];

Nsarray *lines=[strings componentsseparatedbystring:@ "\ n"];

For (NSString *lin in lines) {

Nsarray *content=[lin componentsseparatedbystring:@ "&"];

Menu *men=[menu New];

MEN.NAME=CONTENT[0];

MEN.TAGP=CONTENT[1];

MEN.INTRODUCE=CONTENT[2];

MEN.IMAGE=CONTENT[3];

MEN.MATERIOL=CONTENT[4];

MEN.BURDENING=CONTENT[5];

[Self.menus Addobject:men];

Lan Yi iOS learning TableCell recipe Exercises

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.