Lan Yi iOS Global local variable/for loop/uilabel

Source: Internet
Author: User

Tense and busy day, this afternoon Liu Guobin lecturer talked about things almost didn't keep up, because is 0 basis, for loop there did not understand, fortunately during the recess teacher Liu very patient and told me again. I spent more than two hours in the evening and contacted him several times. The following summarizes my harvest today.

1,uilabel

Click on the event that occurs on the screen

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{

Text to int, with intvalue//int to text with @ (). StringValue

int Currentconent=[_lb.text Intvalue]; Force the uilable text to be converted into integers

[Email protected] (currentconent). stringvalue;//global variable change text to integers

2,uitextfield

Usage of 3,IF statements

4, logical operators && | |

5, three-step expression

int a=1;

int b=2;

int c=a>b?8:9;

NSLog (@ "%d", c);

6,for Cycle

Inside for loop i is the control horizontal, outside the For Loop J Control line number, outside J unchanged, consider inside for loop I change

Lower right triangle ********//

for (int j=0; j<50; J + +) {

for (int i=50;i>=50-j; i--) {//is the middle plus = number, the effect is not to start printing from the first row

Uilabel*kk=[[uilabel Alloc]initwithframe:cgrectmake (6*i, 6*j, 5, 5)];

Kk.backgroundcolor=[uicolor Redcolor];

[Self.view ADDSUBVIEW:KK];

}

}

********* left Lower Triangle ********//

for (int j=0; j<50; J + +) {

for (int i=0; i<j;i++) {

Uilabel*kk=[[uilabel Alloc]initwithframe:cgrectmake (6*i, 6*j, 5, 5)];

Kk.backgroundcolor=[uicolor Redcolor];

[Self.view ADDSUBVIEW:KK];

}

}

Upper left Triangle ********//

for (int j=0; j<50; J + +) {

for (int i=0; i<50-j;i++) {

Uilabel*kk=[[uilabel Alloc]initwithframe:cgrectmake (6*i, 6*j, 5, 5)];

Kk.backgroundcolor=[uicolor Redcolor];

[Self.view ADDSUBVIEW:KK];

}//    }

Upper right triangle ********//

for (int j=0; j<50; J + +) {

for (int i=0;i<j;i++) {

Uilabel*kk=[[uilabel Alloc]initwithframe:cgrectmake (6*j, 6*i, 5, 5)];

Kk.backgroundcolor=[uicolor Redcolor];

[Self.view ADDSUBVIEW:KK];

}

}

Lan Yi iOS global local variable/for loop/uilabel

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.