As an intern I am 1, 3, 5 in the Office, 2, 4, 6 go to another place to listen to Learning iOS (APP) courses, in order not to drop the course, I am prepared to teach each night the course of the fall, I do not understand the note to listen to the teacher when asked, I hope that they can keep up with the pace of learning This lesson was heard a few days ago, and is written together today.
Lesson Two: IOS (APP) uiimage control and TextField control, the code is as follows
One: UIImage control code: Add a picture to the view and set the size, there is no picture background of the color settings, I guess there should be no need to set it, because there is no button function, the background color can not be seen.
Setting the background color is involved in the following TextField.
#import "ViewController.h"
@interface Viewcontroller ()
@end
@implementation Viewcontroller
-(void) viewdidload
{
[Super Viewdidload];
Create a new UIImage object and request space for it in memory
UIImage Im1=[[uiimage Alloc] init];//can also create objects UIImage *im1=[[uiimage alloc]initwithframe:cgrectmake (30,40,80,80)]; This is faster.
Set the location and size of an image
Image.frame=cgrectmake (30,40,80,80);
Add a picture to the view
Im1.image=[uiimage imagenamed:@ "Abc.jpg"];
Add Object im1 to Self.view
[Self.view addsubview:im1];//If IM1 is also written in the image can not? Why?
}
-(void) didreceivememorywarning
{
[Super didreceivememroywarning];//A total of four lines of code, to achieve the image add and position size.
}
@end
II: Learning of Uitextfield controls
Implementing the editing of a text box
#import "ViewController.h"
@implmentation Viewcontroller () <uitextfielddelegate>//Add agent
-(void) viewdidload
{
[Super Viewdidload];
In general, the text box is white, because we need to set the view background to black, so it is easier to see the effect, other colors can also
Self.view.backgroundcolor=[uicolor Blackcolor];
Create a TextField object and set the location and size
Uitextfield *tfd=[[uitextfield Alloc]initwithframe:cgrectmak (60,60,50,50,)];
Set the background color of an object tfd
Tfd.backgroundcolor=[uicolor whitecolor];//I have tried, can also write [TfD setbackgroundcolor:uicolor Whitecolor];
Set yourself as a proxy
tfd.delegate=self;
Text One-click Clear Settings
Tfd.cleanbuttonmode=yes;
Add to Self.view
[Self.view ADDSUBVIEW=TFD];
}
Set the first response, this I understand is not very thorough, but know how the effect is, when the input is complete, click on the blank space of the keyboard input box will automatically exit.
-(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField
{
return [TfD Resignfirstresponder];
}
-(void) didreceivememorywarning
{
[Super didreceivememorywarning];
}
@end
UIImage control and Uitextfield control a lot of code is not very understanding, just know the general meaning and implementation of the function, the teacher said to remember this first, later talk about. Yes, I feel like I should know right now.
Only try to understand, if you have a master, you can help me add some comments, let me know how each part of the function is how to achieve, thank you master to guide!
2015.11.01 21:58
Lesson Two: IOS (APP) uiimage controls and TextField control learning