Day-02

作者: 清杨程 | 来源:发表于2019-06-09 19:19 被阅读0次

第一节 程序启动过程

1.了解main函数

  1. 掌握 UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    1>参数:参数1:argc 参数2:argv 参数3:nil。UIApplication 类名或子类名,默认nil代表UIApplication。参数4:UIApplication代理名。
    2> NSStringFromClass:作用:把类名转为字符串。好处:有提示、避免输入错误。
    3.UIApplicationMain底层实现功能
    1>根据参数2传递的类名创建UIApplication对象。
    2>创建UIApplication代理对象,指定UIApplication对象设置代理。
    3>开启主运行事件循环,处理事件。
    4>加载info.plist文件,判断是否指定main,如果是指定加载。
    4.了解run loop
    5.程序的启动过程
    1>打开程序->执行main函数->执行UIApplicationMain函数->初始化UIApplication(创建和设置代理,开启事件循环)->监听系统事件。

第二节 UIWindow

1.了解UIWindow

  1. 创建UIWindow
//1、创建窗口
  self.window= [[UIWindowalloc] initWithFrame:[UIScreenmainScreen].bounds];
//2、创建跟控制器
UIViewController*rootVc = [[UIViewControlleralloc] init];
//3、设置窗口的跟控制器(底层原理了解1、[self.window addSubview:rootVc.view]2、旋转功能)self.window.rootViewController= rootVc;
//4、显示窗口(底层原理了解1、self.window.hidden = NO2、设置主窗口)
 [self.windowmakeKeyAndVisible];
  1. 窗口的层级
 //5、补充窗口层级
self.window.windowLevel= UIWindowLevelNormal;

4.了解常见的窗口状态栏、键盘以及获取窗口的个数

第三节 创建控制器

1.代码创建
UIViewController*Vc = [[UIViewControlleralloc] init];
2. Storyboard创建
UIStoryboard*storyboard = [UIStoryboardstoryboardWithName:@"Main"bundle:nil];
//UIViewController *Vc = [storyboard instantiateInitialViewController];//加载默控制器
UIViewController*Vc = [storyboard instantiateViewControllerWithIdentifier:@"green"];//加载指定控制器
3. Xib创建
ViewController*vc = [[ViewControlleralloc] initWithNibName:@"Vc"bundle:nil];    
![无标题.png](https://img.haomeiwen.com/i2235937/8133cd386771c43a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

第四节 控制器View

1.了解loadView
2.自定义控制器view(底层的实现)
3.通过XIB加载控制器View(没有重写loadView且控制器名以Controller结尾)
1>先判断有没有指定nibName,指定了加载指定的xib
2>判断有没有“控制器前缀+View”的XIB,有加载
3>判断有没有和控制器同名的XIB,有加载
4>直接创建空的XIB

第五节 UIPicker View

1.UIPickerView的创建
2.UIPickerView的代理方法
3.UIPickerView的多级联动

#pragma mark -UIPickerViewDataSource
//返回有多少列
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView*)pickerView;
//返回第component列多少行
- (NSInteger)pickerView:(UIPickerView*)pickerView numberOfRowsInComponent:(NSInteger)component;
#pragma mark -UIPickerViewDelegate
//返回第component列的宽度
- (CGFloat)pickerView:(UIPickerView*)pickerView widthForComponent:(NSInteger)component;
//返回第component列的高度
- (CGFloat)pickerView:(UIPickerView*)pickerView rowHeightForComponent:(NSInteger)component;
//返回第component列rowg行的标题
- (nullable NSString*)pickerView:(UIPickerView*)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
//返回第component列rowg行的富文本
- (nullableNSAttributedString*)pickerView:(UIPickerView*)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component;
//返回第component列rowg行控件
- (UIView*)pickerView:(UIPickerView*)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(nullable UIView*)view;
//选中事件
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;

3.UIPickerView数据取出
1>plist文件(懒加载)

@property(nonatomic,strong) NSArray*foods;
- (NSArray*)foods{
   if(_foods==nil) {
       NSString*filePath = [[NSBundlemainBundle] pathForResource:@"foods.plist"ofType:nil];
       _foods= [NSArrayarrayWithContentsOfFile:filePath];
   }
   return _foods;
}

2>网络数据

第六节 UITextField

  1. UITextField的创建

2.UITextField的代理方法

#pragma mark -UITextFieldDelegate
//是否循序文本字段开始编辑
- (BOOL)textFieldShouldBeginEditing:(UITextField*)textField;
//开始编辑时触发
- (void)textFieldDidBeginEditing:(UITextField *)textField;
//是否允许文本字段结束编辑
- (BOOL)textFieldShouldEndEditing:(UITextField*)textField;
//结束编辑
- (void)textFieldDidEndEditing:(UITextField *)textField;
//是否允许改变内容
- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string;
//否允许根据用户请求清除内容
- (BOOL)textFieldShouldClear:(UITextField *)textField;
//是否允许在按下回车键时结束编辑
- (BOOL)textFieldShouldReturn:(UITextField*)textField;

3.UITextField的键盘自定义
1>、inputView 属性
2>、Plist文件的存取

 NSString*filePath = [[NSBundlemainBundle] pathForResource:@"xxx.plist"ofType:nil];
NSArray*fileArray = [NSArrayarrayWithContentsOfFile:filePath];

3>、字典转模型的实现
3>、KVC的底层原理
字典遍历->调用set的方法
4、UIDatePicker的知识点
1>UIDatePicker的创建

UIDatePicker*datePicker = [[UIDatePickeralloc] init];
    datePicker.locale= [NSLocalelocaleWithLocaleIdentifier:@"zh"];
   datePicker.datePickerMode= UIDatePickerModeDate;
  [datePicker addTarget:selfaction:@selector(datePickChange:)forControlEvents:UIControlEventValueChanged];

2>日期格式的设置

NSDateFormatter*dateFormatter = [[NSDateFormatteralloc] init];
  dateFormatter.dateFormat= @"yyyy-MM-dd";

相关文章

  • 2018-09-26

    Day-02 总结 Python基础 01-认识python control+/ 添加注释/取消注释contr...

  • day-02

    作业 day2作业:1.下列四组数,依次为二进制、八进制和十六进制,符合要求的是(D)a. 12, 77, 1...

  • Day-02

    第一节 程序启动过程 1.了解main函数 掌握 UIApplicationMain(argc, argv, ni...

  • Day-02

    python基础 本周内容安排: 变量 运算符 数据类型 分支和循环结构 python没有编译的过程 是一种解释性...

  • day-02 作业

    1.写代码获取数字1234中的十位上和百位上的数字 a=1234b = a // 10 % 10print(b)3...

  • day-02总结

    python的基础语法 一、快捷键 ctrl+/ 添加或者取消一行注释 ctrl+s 保存 ctrl+...

  • canvas day-02

    canvas标签 属性 width height 方法 getContext() 参数 “2d” "webgl"...

  • linux Day-02

    1.vim vi 是什么? Vim是从 vi 发展出来的一个文本编辑器。 2.vim有哪几种模式? 三种模式,命令...

  • Liunx操作day-02

    演示命令:yangyang@yangyang-virtualmachine:~ ls /home/yangyang...

  • Java学习-练习-Day-02

    题目来源:《疯狂Java讲义》

网友评论

      本文标题:Day-02

      本文链接:https://www.haomeiwen.com/subject/qwmnxctx.html