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