IOS development-UI from entry to entry (3), ios-ui

Source: Internet
Author: User

IOS development-UI from entry to entry (3), ios-ui

IOS development-UI from entry to mastery (3) is a comprehensive exercise on iOS development-UI from entry to mastery (1) knowledge points, build a simple login interface, and enhance practical experience, lay a solid foundation for future development!

※Here, we also want to emphasize the considerations for the development environment and memory management (the last emphasis will not be shown in future articles, and we hope you will keep it in mind ):

 

1. In the early stage of iOS-UI development, we need to manually manage the memory, so we need to turn off the ARC (the steps for Xcode to turn off the ARC );

 

(1) Open Xcode and select the current project:

 

 

(2) Select Build Settings:

 

 

(3) Enter count in the input box:

 

 

(4) select Objective-C Automatic Reference Counting to set it to NO:

 

 

(5) In the AppDelegate. h file, change @ property (assign, nonatomic) UIWindow * window to @ property (retain, nonatomic) UIWindow * window;

 

(6) rewrite the AppDelegate. m file:-(void) dealloc {[_ window release]; [super dealloc];}

 

2. during development, we will use the simulator. Next let's take a look at the steps for adding the simulator (in the Xcode environment );

 

(1) Open the Devices in Xcode Window:

 

(2) Click "+" and select the Simulator Name in the displayed selection box:

 

1. Use the learned knowledge to build a simple login interface that displays "Account", "password", "login", "forgot password", "Registration", and so on:

AppDelegate. h file:

1 #import <UIKit/UIKit.h>2 3 @interface AppDelegate : UIResponder <UIApplicationDelegate>4 5 @property (retain, nonatomic) UIWindow *window;6 7 @end

In the AppDelegate. m file:

 

1 @ implementation AppDelegate 2 3-(void) dealloc 4 {5 [_ window release]; 6 [super dealloc]; 7} 8 9-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {10 // Override point for customization after application launch.11 # pragma mark --: window 12 self. window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen] bounds]; 13 14 _ window. backgroundColor = [UIColor whiteColor]; 15 16 # pragma mark --: Create a view17 UIView * view = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] bounds]; 18 19 view. backgroundColor = [UIColor whiteColor]; 20 21 # pragma mark --: create two UILabel (account \ Password) 22 UILabel * numLabel = [[UILabel alloc] initWithFrame: CGRectMake (60,100, 50, 30)]; 23 24 numLabel. text = @ "account:"; 25 26 UILabel * passLabel = [[UILabel alloc] initWithFrame: CGRectMake (60,160, 50, 30)]; 27 28 passLabel. text = @ "Password:"; 29 30 # pragma mark --: create two UITextField (account input box \ Password Input box) 31 UITextField * numTextField = [[UITextField alloc] initWithFrame: CGRectMake (130,100,200, 30)]; 32 33 numTextField. borderStyle = UITextBorderStyleRoundedRect; 34 35 numTextField. placeholder = @ "Enter your mobile phone number/Email Address"; 36 37 UITextField * passTextField = [[UITextField alloc] initWithFrame: CGRectMake (130,160,200, 30)]; 38 39 passTextField. borderStyle = UITextBorderStyleRoundedRect; 40 41 passTextField. placeholder = @ "Enter Password"; 42 43 # pragma mark --: create three buttons (LOGIN \ forgot password \ register) 44 UIButton * loginBtn = [UIButton buttonWithType: uibuttontonpestypesystem]; 45 46 loginBtn. frame = CGRectMake (60,220, 40, 40); 47 48 [loginBtn setTitle: @ "login" forState: UIControlStateNormal]; 49 50 UIButton * forgetBtn = [UIButton buttonWithType: Success]; 51 52 forgetBtn. frame = CGRectMake (160,220, 60, 40); 53 54 [forgetBtn setTitle: @ "forgot password" forState: UIControlStateNormal]; 55 56 UIButton * regisBtn = [UIButton buttonWithType: Success]; 57 58 regisBtn. frame = CGRectMake (280,220, 40, 40); 59 60 [regisBtn setTitle: @ "register" forState: UIControlStateNormal]; 61 62 # pragma mark --: add to view 63 [view addSubview: regisBtn]; 64 65 [view addSubview: forgetBtn]; 66 67 [view addSubview: loginBtn]; 68 69 [view addSubview: passTextField]; 70 71 [view addSubview: numTextField]; 72 73 [view addSubview: passLabel]; 74 75 [view addSubview: numLabel]; 76 77 [_ window addSubview: view]; 78 79 [_ window makeKeyAndVisible]; 80 81 # pragma mark --: release 82 [passTextField release]; 83 84 [numTextField release]; 85 86 [passLabel release]; 87 88 [numLabel release]; 89 90 [view release]; 91 92 [_ window release]; 93 94 return YES; 95} 96 97 @ end

 

 

 

 

Simulator running:

          

The next article will continuously update related knowledge points and exercises;

Email: dingding3w@126.com

 

Related Article

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.