zoukankan      html  css  js  c++  java
  • iOS开发-UI 从入门到精通(三)

     iOS开发-UI 从入门到精通(三)是对 iOS开发-UI 从入门到精通(一)知识点的综合练习,搭建一个简单地登陆界面,增强实战经验,为以后做开发打下坚实的基础!

    ※在这里我们还要强调一下,开发环境和内存管理注意事项(最后一次强调,以后文章中将不会在出现希望大家谨记):

    1、前期iOS-UI开发我们需要手动管理内存,所以我们要把ARC关掉(Xcode关掉ARC的步骤);

    (1)打开Xcode选中当前工程:

    (2)选中Build Settings:

    (3)在输入框内输入count:

    (4)选择Objective-C Automatic Reference Counting  将其设置为  NO:

    (5)AppDelegate.h文件中将:@property (assign, nonatomic) UIWindow *window;改成@property (retain, nonatomic) UIWindow *window;

    (6)AppDelegate.m文件中重写:- (void)dealloc  {  [_window release];  [super dealloc];  }

    2、在开发当中我们会用到模拟器下面我们来看一下模拟器添加步骤(Xcode环境下);

    (1)打开Xcode选择Window下的Devices:

    (2)点击“+”在弹出来的选择框里对 Simulator Name 进行选择:

    一、利用所学的知识搭建一个简单地登陆界面界面呈现“账号”、“密码”、“登录”、“忘记密码”、“注册”等:

    AppDelegate.h文件中:

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

    AppDelegate.m文件中:

     1 @implementation AppDelegate
     2 
     3 - (void)dealloc
     4 {
     5     [_window release];
     6     [super dealloc];
     7 }
     8 
     9 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(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--:创建一个view
    17     UIView * view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    18     
    19     view.backgroundColor = [UIColor whiteColor];
    20     
    21 #pragma mark--:创建两个UILabel(账号密码)
    22     UILabel * numLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 100, 50, 30)];
    23     
    24     numLabel.text = @"账  号:";
    25     
    26     UILabel * passLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 160, 50, 30)];
    27     
    28     passLabel.text = @"密  码:";
    29     
    30 #pragma mark--:创建两个UITextField(账号输入框密码输入框)
    31     UITextField * numTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 100, 200, 30)];
    32     
    33     numTextField.borderStyle = UITextBorderStyleRoundedRect;
    34     
    35     numTextField.placeholder = @"请输入手机号/邮箱";
    36     
    37     UITextField * passTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 160, 200, 30)];
    38     
    39     passTextField.borderStyle = UITextBorderStyleRoundedRect;
    40     
    41     passTextField.placeholder = @"请输入密码";
    42     
    43 #pragma mark--:创建三个Button(登录忘记密码注册)
    44     UIButton * loginBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    45     
    46     loginBtn.frame = CGRectMake(60, 220, 40, 40);
    47     
    48     [loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    49     
    50     UIButton * forgetBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    51     
    52     forgetBtn.frame = CGRectMake(160, 220, 60, 40);
    53     
    54     [forgetBtn setTitle:@"忘记密码" forState:UIControlStateNormal];
    55     
    56     UIButton * regisBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    57     
    58     regisBtn.frame = CGRectMake(280, 220, 40, 40);
    59     
    60     [regisBtn setTitle:@"注册" forState:UIControlStateNormal];
    61     
    62 #pragma mark--:添加到视图上
    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--:释放
    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

    模拟器运行效果图:

              

    下一篇将持续更新配套知识点及练习;

     Email:dingding3w@126.com

  • 相关阅读:
    Powershell数据处理
    Powershell About Active Directory Group Membership of a domain user
    Powershell About Active Directory Server
    Oracle Schema Objects——Tables——TableStorage
    Oracle Schema Objects——Tables——TableType
    English Grammar
    Oracle Database Documentation
    Oracle Schema Objects——Tables——Oracle Data Types
    Oracle Schema Objects——Tables——Overview of Tables
    What is Grammar?
  • 原文地址:https://www.cnblogs.com/dingding3w/p/4625600.html
Copyright © 2011-2022 走看看