iOS 2nd day

Source: Internet
Author: User
<span id="Label3"></p><p>Tittle button<br>Backgroundrectforbounds<br>Tittlerectforcontentrect the frame of the internal label of the controller<br>Imagerectforcontentrect//controller Internal ImageView Frame<br><br>CGFloat<br>CGFloat<br>CGRectMake<br><br>Click a button, only error, dead loop!!<br>Awakefromnib<br>When an object is parsed from a file, it is called<br><br><br><br>The law of software development: everything is Object<br>UIKit: Creating and managing the application user interface<br>Image Object: Uiimageview<br>Text label Object: UILabel<br>Button Object: UIButton<br><br>Use the classes provided by the Uikit framework to create a variety of visual build objects and finally make a complex and beautiful UI interface<br>Improve Learning Efficiency:<br>1. Understand ideas and find Patterns.<br>2. Do not look at the code after class Knocks.<br>3. Learning is a problem, not learning the answer, learn to find problems, solve problems<br><br>A simple addition calculator:<br>Stroyboard File: describes the interface, the left arrow refers to the Interface: Program-start will be displayed<br>Option key, Drag<br>Change to numeric keypad: attribute Keyboardtype<br>Drag line Implementation button click Event:<br>All you can order is a button!<br>You can enter text is the text box!<br><br>UIView ancestor (control, build) of all controls: function 1. Display control; 2. Acquisition controls<br>UIButton, UILabel, Uitextfield<br>Each of the UIView is a container that can accommodate other UIView<br>Uiviewcontroller effect:<br>First create a uiviewcontroller, and then create a large UIView<br>Controller's relationship to view: how the view is created, how it is destroyed, and some of the triggering events of the child controls, all of which have controllers to Implement. In a word, the controller is used to manage the view, including the creation and destruction of uiview, UIView interaction with the user<br><br><br>Listener events Write code in the class of the controller<br><br>Class extension<br>Ibaction represents void, but indicates that it can drag (correlate) the Line.<br>line, Delete<br><br>Get the contents of the text box:<br>Drag!!!<br>The properties in the controller are associated with controls on the interface outlet (build properties) action Generation method<br><br>Implementing the Calculation function steps<br>!. Get the User's input<br>Calculation and<br>Show the results on the interface<br><br>The string type is converted to int<br>int n1 = [NUM1 intvalue];<br>int n1 = num2.intvalue;<br>NSString int:<br>[nsstring stringwithformat:@ "@%d", result];<br><br>Retract keyboard operation<br>Firstresponsor first Responder: who called the keyboard, who is called the first responder<br>1. Let the first responder resign and the keyboard shrinks Back. Use the [num1resignfirstresponder] method.<br>2. Locate the view that the current controller controls, so that all of its internal controls stop editing Work. In this case, any keyboard that is called by the View's child control will Go. [self.view endediting YES]<br><br>Self represents the current viewcontroller, and Self.view represents the view that the current controller Manages.<br><br>Ibaction Iboutlet is equivalent to void, but allows us to drag the line<br><br>Child control, which is the relationship between the container and its internal controls<br><br><br>Deployment Target: currently developing the lowest running version<br><br>Main Interface: which storyboard to start when the program starts<br><br>Bundle Identifier: Version<br><br>Arrow: the controller that starts when the program starts (if you don't see the arrow tick is initial Viewcontrollor)<br><br>Program start-up configuration main.storyboard-> arrows point to the class name of the Controller-> configuration, create a controller--create a view<br>Text box: placeholder (user input text will automatically disappear) secure (password text box mask Display)<br>The Clear button appears to the right of the text box. Clear button default Value: never appears<br>text box can only enter Numbers: keyboard property<br><br>Button: can display the text, the picture, but also can adjust the internal picture and the text position at any time<br>There are uikit available<br><br>Functional Analysis:<br>Lower left corner 4 directional buttons to control the position of the Avatar<br>The lower right corner is zoom in, Zoom out button, control the size of the avatar<br>The Avatar button has both a background image and text<br><br>Step analysis:<br>Building a UI interface<br>Monitor button click<br>Modify the properties of the Avatar button to adjust position and size<br><br>Drag pictures to Images.xcassets<br>Status of the Button: highlight, default state<br>The default type of the button is system and its highlight status is Gray.<br>Can be changed to custom Type.<br><br><br>Drag Line: method 2: Right-click the control, select event, wire to the extension of the code<br><br>Gets the coordinates of the button: gets the frame value of the original button (is the type of the cgrect, the packet expands by two values: point and size, where point packet expands cgfloat x, cgfloat y, size includes width, and height);<br>CGRect Orignframe = self.btnIcon.frame; Get the frame of the icon<br>originframe.origin.y-= 10;//set Y-value<br>Self.btnIcon.frame = originframe;//assigns A new frame to the button<br><br>To modify control coordinate steps:<br>Get the original frame value<br>Modify Frame<br>Re-assign the new frame value to the control<br><br>When the OC object property is a struct type, the value of the property cannot be directly modified, the specified<br><br>Create Size:cgsizemake () to create a rect cgrectmake<br><br>The button that sender is currently being clicked as a parameter<br><br>Any control has a tag property to mark the control,<br>Use Sender.tag to determine the User's current click is that button<br><br>Get the original frame<br>Modify Frame<br>Pass the modified value to the original frame<br><br>Frame (contains position and size x, y represents the coordinates of the Upper-left corner) CGRect<br>Center (can only Modify position, which represents the coordinates of the center point of the Control) cgsize<br>Bounds (modify Size) CGRect<br>Transform (swivel)<br><br><br>Nsstringfromcgrect ();<br><br>Add animations in two different ways<br>1. Tail type<br>1). Turn on animation<br>[UIView Beginanimations:nil context:nil];<br>2). Set animation Execution Time<br>[UIView setanimationduration:2];<br>———— Middle Here is the code for the animation to be executed----------------<br>3). Submit Animation<br>[UIView commitanimations]<br>2. Block type<br>1). [UIView animatewithduration: Duration animations:^{<br>Self.btnIcon.frame = orignframe;<br>}];<br><br>When you want to display an interface, first create the interface corresponding to the controller, the controller is created, and then create the controller to manage the view, when the view has been loaded after the implementation of the following METHOD.<br>So as long as the Viewdidload method is executed, the view that the controller manages is Created.<br><br>Dynamically Create our own buttons<br>1. Create button UIButton *button= [[UIButton alloc]init]<br>Set the text displayed on the Button:[button settitle:@ "dot me" forstate:uicontrolstatenormal] display text in default state<br>[button settitle:@ "touch me what to do" forstate:uicontrolstatehighlighted];<br><br>Set a background picture by default<br>UIImage *imgnormal = [UIImage imagenamed:@ ""];<br><br>[button Setbackgroundimage:imgnormal forstate:uicontrolstatenormal];<br>Set the background picture in the highlighted state<br>[button setbackgroundimage:imghighlighted forstate:uicontrolstatehighlighted];<br>Set text color in different states<br>[button Settitlecolor:[uicolor redcolor] forstate:uicontrolstatenormal];<br>[button Settitlecolor:[uicolor bluecolor] forstate:uicontrolstatehighlighted]<br>Set the frame of the button<br>Button.frame=cgrectmake (50, 100, 100, 100);<br>Add dynamically created buttons to the view managed by the controller<br>[self.view addsubview:button] Adding a Word control<br>[self.view removefromsuperview;] Remove from parent control<br>Registering a click event with the code for a button<br>[button addtarget:self action: @selector (buttonclick) forcontrolevents:uicontroleventtouchupinside];<br><br>Remove AutoLayout<br>1. If you find that you cannot modify the position or size of the control through the code, you should remove the AutoLayout function inside the storyboard, which is a feature that starts from the IOS6<br>2. As the name implies, AutoLayout is used for automatic layout, used to harness the position and size of the control, remove this function, the position and size of the control is no longer a fixed bundle?<br><br><br><br>Image format in PNG format can be omitted<br><br><br>The Transform property can modify the Control's displacement, scaling, rotation<br>Create a Transform property<br>Cgaffinetransform cgaffinetransformmaketransaltion (cgfloat tx, cgfloat ty)//panning<br>Cgaffinetransform cgaffinetransformmakescale (cgfloat sx, cgfloat sy); Scaling<br>Cgaffinetransform cgaffinetransformmakerotation (cgfloat Angle)<br>Rotating<br>Overlay on the basis of a transform<br>Cgaffinetransform cgaffinetransformtranslate (cgaffinetransform t, cgfloat tx, cgfloat ty);<br>Cgaffinetransform cgaffinetransformscale (cgaffinetransform t, cgfloat sx, cgfloat sy);<br>Cgaffinetransform cgaffinetransformrotate (cgaffinetransform t, cgfloat angle);<br><br>Clears the previously set transform property<br>View.transform = cgaffinetransformidentity;<br><br><br>@property (nonatomic, readonly) UIView *superview; Get your own parent control to member<br>*subview: getting your own child controls<br><br>Self.view.subviews gets all the word controls for the Control.<br><br>To get a control based on tag<br>[self.view View withtag:1000]<br><br>Picture frame: don't do anything, just file box<br><br>plist, file, save; data files are created in the property list, resource<br><br><br>Dictionary can save multiple values<br><br><br>Write code to load the data in the Pic.plist file to _pic<br>Get a passage of pic.plist file<br>Gets the path of the Pic.plist file assigned to the PATH variable<br>[nsbundle mainbundle] indicates the root directory when the app is installed on the phone, and then searches the path of the Pic.plist file in the root directory of the App's installation<br>NSString *path = [[nsbundle mainbundle] pathforresource:@ "pic.plist" oftype:nil]<br>NSString *path =[[nsbundle mainbundle]pathforresource:@ "pic" oftype:@ "plist"]; Either way<br><br><br>Nsarray *array = [nsarray arraywithcontentsoffile:path]; Read the file for the path<br><br><br>Write a draw control what is currently displayed is the first few pictures<br>1. Let Index + +<br>self++<br>Gets the current image data from the array<br>Nsdictionary *dic = self.pic[self.index];<br>3 Set the acquired data to the controls on the interface<br>Self.lblIndex.text = [nsstring stringwithformat:@ "%d/%ld", self.index, self.pic.count];<br>Self.imgViewIcon.image = [UIImage imagenamed:dict[@ "icon"]] Use the Image property to set the picture inside the picture frame//<br>Self.liblTitle.text = dict[@ "title"];<br>Lazy Loading Data<br><br>Controls whether the previous and next sheets are available<br><br><br>How to create a new plist file<br>Nsdictionary Assignment Value:<br>Nsdictionary *dict1 = @{@ "name": @ "liliy", @ "age": @18, @ "height": @189};<br>Nsarray *students = @[dict1, dict2, dict3];<br>NSLog (@ "%@", students); ; output<br>The new plist (empty) path<br><br>Plist is essentially an XML file<br><br><br><br><br>Uiimageview Frame Animation related properties:<br>@property (nonatomic, copy) nsarray* animationimages;<br>The sequence frame picture that needs to be played () inside are all uiimage, will display the picture in order<br><br>@property (nonatomic) Nstimeinterval animatonduration;<br>Duration of frame animation<br>@property (nonatomic) Nsinteger animationrepeatcount;<br>Number of execution times for frame animations (default is infinite loop)<br>-(void) start| animating;<br>Start to perform frame animation<br><br>-(void) stopanimating;<br>Stop performing frame animations<br>-(Bool) isanimating;<br>Whether frame animation is being performed<br><br><br>1 loading images dynamically into a nsarray<br><br>Load a picture into memory<br>UIImage *img = [UIImage imagenamed:@ "drink_00.jpg"]<br>2 Set the Animationimages property of the Uiimageview (picture box), which contains all the pictures that are animated<br>3 Set Animation duration<br>4 Setting the animation requires Fuji Replay<br>5 Opening animations<br><br><br>%02d reserved two-bit<br><br><br>Through the [UIImage imagenamed:imgname] program will be cached, will not free memory, the picture will be kept in memory, so the next time you use the same image, you do not need to reload the latest version because the memory is already there. The downside is that if you load a large number of images, the images remain in memory, causing the application to take up too much memory (called Caching)<br>Workaround<br>UIImage *imgcat = [UIImage imagewithcontentsfile: Complete Road warp]<br><br>How to get the full path:<br>NSString *path = [nsbundle mainbundle] pathforresource:imgname oftype:nil] so get to the end of the path<br><br>After you run out of pictures, clear the pictures in memory<br>[self.imgviewcat performselector: @selector (setanimationimages:) withobject:nil afterdelay: Lef.imgViewCat.animationImages.count * 0.1]<br><br></p><p><p>iOS 2nd day</p></p></span>

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.