知识点扩展

1.IBAction:
1> 能保证方法可以连线
2> 相当于void

2.IBOutlet:
1> 能保证属性可以连线

3.常见错误
setValue:forUndefinedKey:]: this class is not key value coding
错误原因是:连线出问题了

4.Xcode5开始的一些建议
把用于连线的一些方法和属性声明在.m文件的类扩展中

5.framecenterounds
1> frame:能修改位置和尺寸
2> center:能修改位置
3> bounds:能修改尺寸(xy一般都是0)

-----------------------------------------------------------------------------------------------------

1.NSBundle
1> 一个NSBundle代表一个文件夹,利用NSBundle能访问对应的文件夹
2> 利用mainBundle就可以访问软件资源包中的任何资源
3> 模拟器应用程序的安装路径
/Users/aplle/资源库/Application Support/iPhone Simulator/7.1/Applications

2.UIImageView和UIButton
1> 使用场合
* UIImageView: 如果仅仅是显示图片,不需要监听图片的点击
* UIButton: 既要显示图片,又要监听图片的点击

2> 相同:能显示图片

3> 不同点
* UIButton能处理点击事件, UIImageView不能处理点击事件
* UIButton既能显示图片, 又能显示文字
* UIButton能同时显示两张图片
* UIButton继承自UIControl, 因此默认就能处理事件
* UIImageView继承自UIView, 因此默认就不能处理事件

3.Xcode文档安装路径
/Applications/Xcode.app/Contents/Developer/Documentation/DocSets

4.Xcode模拟器安装路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs

-----------------------------------------------------------------------------------------------------

1.Xcode自带头文件的路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/Frameworks/UIKit.framework/Headers

2.修改了系统自带头文件后,Xcode会报错
解决方案:删掉下面文件夹的缓存即可(aplle是电脑的用户名)
/Users/aplle/资源库/Developer/Xcode/DerivedData
或者
/Users/aplle/Library/Developer/Xcode/DerivedData

3.使用xib封装一个自定义view的步骤
1> 新建一个继承UIView的自定义view,假设类名叫做(MJAppView)
2> 新建一个MJAppView.xib文件来描述MJAppView内部的结构
3> 修改UIView的类型为MJAppView真是类型
4> 将内部的子控件跟MJAppView进行属性连线
5> MJAppView提供一个模型属性
6> 重写模型属性的set方法,因为在set方法中可以拿到外界传递的模型数据
7> 把模型数据拆开,分别设置数据到对应的子控件中
8> 补充:提供一个创建MJAppView的类方法,将读取xib文件的代码屏蔽起来

-----------------------------------------------------------------------------------------------------

1.Xcode插件的安装路径(可以在这里删除内容来卸载插件)
(aplle是用户名)
/Users/aplle/Library/Application Support/Developer/Shared/Xcode/Plug-ins

2.UIView自带的方法
1> - (void)layoutSubviews;
* 当一个控件的frame发生改变的时候就会自动调用
* 一般在这里布局内部的子控件(设置子控件的frame)
* 一定要调用super的layoutSubviews方法

2> - (void)didMoveToSuperview;
* 当一个控件被添加到父控件中就会调用

3> - (void)willMoveToSuperview:(UIView *)newSuperview;
* 当一个控件即将被添加到父控件中会调用

-----------------------------------------------------------------------------------------------------

一.UIPickerView
1.UIPickerView的常见属性
// 数据源(用来告诉UIPickerView有多少列多少行)
@property(nonatomic,assign) id<UIPickerViewDataSource> dataSource;
// 代理(用来告诉UIPickerView每1列的每1行显示什么内容,监听UIPickerView的选择)
@property(nonatomic,assign) id<UIPickerViewDelegate> delegate;
// 是否要显示选中的指示器
@property(nonatomic) BOOL showsSelectionIndicator;
// 一共有多少列
@property(nonatomic,readonly) NSInteger numberOfComponents;

2.UIPickerView的常见方法
// 重新刷新所有列
- (void)reloadAllComponents;
// 重新刷新第component列
- (void)reloadComponent:(NSInteger)component;

// 主动选中第component列的第row行
- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated;

// 获得第component列的当前选中的行号
- (NSInteger)selectedRowInComponent:(NSInteger)component;

3.数据源方法(UIPickerViewDataSource)
// 一共有多少列
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
// 第component列一共有多少行
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;

4.代理方法(UIPickerViewDelegate)
// 第component列的宽度是多少
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component;
// 第component列的行高是多少
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component;

// 第component列第row行显示什么文字
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;

// 第component列第row行显示怎样的view(内容)
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view;

// 选中了pickerView的第component列第row行
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;

二.UIDatePicker
1.常见属性
// datePicker的显示模式
@property (nonatomic) UIDatePickerMode datePickerMode;
// 显示的区域语言
@property (nonatomic, retain) NSLocale *locale;

2.监听UIDatePicker的选择
* 因为UIDatePicker继承自UIControl,所以通过addTarget:...监听

三.程序启动的完整过程
1.main函数

2.UIApplicationMain
* 创建UIApplication对象
* 创建UIApplication的delegate对象

3.delegate对象开始处理(监听)系统事件(没有storyboard)
* 程序启动完毕的时候, 就会调用代理的application:didFinishLaunchingWithOptions:方法
* 在application:didFinishLaunchingWithOptions:中创建UIWindow
* 创建和设置UIWindow的rootViewController
* 显示窗口

3.根据Info.plist获得最主要storyboard的文件名,加载最主要的storyboard(有storyboard)
* 创建UIWindow
* 创建和设置UIWindow的rootViewController
* 显示窗口

-----------------------------------------------------------------------------------------------------

 
 

1.tableView的刷新
1> 数据刷新的总体步骤
* 修改模型数据
* 刷新表格(刷新界面)

2> 刷新表格(刷新界面)的方法
* 全局刷新(每一行都会重新刷新)
- (void)reloadData;

* 局部刷新(使用前提: 刷新前后, 模型数据的个数不变)
- (void)reloadRows:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;

* 局部删除(使用前提: 模型数据减少的个数 == indexPaths的长度)
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;

2.@property属性的用法
* weak(assign) : 代理UI控件
* strong(retain) : 其他对象(除代理UI控件字符串以外的对象)
* copy : 字符串
* assign : 非对象类型(基本数据类型intfloatBOOL枚举结构体)

原文地址:https://www.cnblogs.com/chenziqiang/p/4930544.html