iOS开发-UI 从入门到精通(三)
2015-07-06 22:29
701 查看
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文件中:
AppDelegate.m文件中:
模拟器运行效果图:
下一篇将持续更新配套知识点及练习;
Email:dingding3w@126.com
※在这里我们还要强调一下,开发环境和内存管理注意事项(最后一次强调,以后文章中将不会在出现希望大家谨记):
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文件中:
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (retain, nonatomic) UIWindow *window; @end
AppDelegate.m文件中:
@implementation AppDelegate - (void)dealloc { [_window release]; [super dealloc]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. #pragma mark--:window窗口 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _window.backgroundColor = [UIColor whiteColor]; #pragma mark--:创建一个view UIView * view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; view.backgroundColor = [UIColor whiteColor]; #pragma mark--:创建两个UILabel(账号\密码) UILabel * numLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 100, 50, 30)]; numLabel.text = @"账 号:"; UILabel * passLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 160, 50, 30)]; passLabel.text = @"密 码:"; #pragma mark--:创建两个UITextField(账号输入框\密码输入框) UITextField * numTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 100, 200, 30)]; numTextField.borderStyle = UITextBorderStyleRoundedRect; numTextField.placeholder = @"请输入手机号/邮箱"; UITextField * passTextField = [[UITextField alloc] initWithFrame:CGRectMake(130, 160, 200, 30)]; passTextField.borderStyle = UITextBorderStyleRoundedRect; passTextField.placeholder = @"请输入密码"; #pragma mark--:创建三个Button(登录\忘记密码\注册) UIButton * loginBtn = [UIButton buttonWithType:UIButtonTypeSystem]; loginBtn.frame = CGRectMake(60, 220, 40, 40); [loginBtn setTitle:@"登录" forState:UIControlStateNormal]; UIButton * forgetBtn = [UIButton buttonWithType:UIButtonTypeSystem]; forgetBtn.frame = CGRectMake(160, 220, 60, 40); [forgetBtn setTitle:@"忘记密码" forState:UIControlStateNormal]; UIButton * regisBtn = [UIButton buttonWithType:UIButtonTypeSystem]; regisBtn.frame = CGRectMake(280, 220, 40, 40); [regisBtn setTitle:@"注册" forState:UIControlStateNormal]; #pragma mark--:添加到视图上 [view addSubview:regisBtn]; [view addSubview:forgetBtn]; [view addSubview:loginBtn]; [view addSubview:passTextField]; [view addSubview:numTextField]; [view addSubview:passLabel]; [view addSubview:numLabel]; [_window addSubview:view]; [_window makeKeyAndVisible]; #pragma mark--:释放 [passTextField release]; [numTextField release]; [passLabel release]; [numLabel release]; [view release]; [_window release]; return YES; } @end
模拟器运行效果图:
下一篇将持续更新配套知识点及练习;
Email:dingding3w@126.com
相关文章推荐
- __builtin_popcount(n)
- IEnumerable和IQueryable区别、优缺点
- NGUI九宫格反向切割拉伸
- LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- easyui-tabs图标(获取焦点时显示图标,失去焦点时隐藏图标)
- 设置UIView圆角 cornerRadius 圆角有性能问题,用贝塞尔曲线代替
- LeetCode || Permutation Sequence
- Swing-布局管理器应用--WIN7上计算器的UI实现
- Davinci内核镜像uImage的编译
- IOS 05 UIScrollView介绍 图片轮播器
- POJ 2785 4 Values whose Sum is 0(折半枚举)
- requirejs 基础
- IOS开发UI篇--一个支持图文混排的ActionSheet
- Kienct与Arduino学习笔记(2) 深度图像与现实世界的深度图的坐标
- 接收终端Request.InputStream阅读
- MYSQL启动后报:ERROR! The server quit without updating PID file错误的问题解决
- Cannot run program "XXXXX/android-sdks/build-tools/aapt.exe": error=2,
- 代理练习 两个UIView界面之间的传值--Delegate
- Codility-task 1-Tape Equilibrium
- 如何不让UITableView滚动