小结
1.按钮的图片设置
按钮的图片有4种状态,Normal,Highlighted,Selected,Disabled
按钮可以有背景图和按钮图片两个图。
2.viewDidLoad的调用时机
view的加载是延迟加载,要使用的时候才加载。
用getter获取self.view时,执行以下操作:

所有的控件或者视图想要显示,必须要addSubview到一个已经显示的视图上
//异步操作,在里面有调用addSubview
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion
- (void)loadView;
在这里创建UIView对象,并设置给self.view
永远不要手动调用
可以在这里自定义self.view,不要在此方法以外的地方改变self.view
3.UIViewController生命周期

第一个页面消失要等到第二个页面显示之后。
4.头文件循环引用解决办法
5.对象之间的数据传递
可以通过属性传值,主要是找到对象,还要想办法让两者碰面。
NSString *str = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
2.数据下载
NSData *data = [NSData dataWithContentsOfURL:url];
3.请求连接类同步下载方法
+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error;
异步:
1.请求连接类异步下载方法
+ (void)sendAsynchronousRequest:(NSURLRequest*) request queue:(NSOperationQueue*) queue completionHandler:(void (^)(NSURLResponse* response, NSData* data, NSError* connectionError)) handler;
2.请求连接类初始化方法异步下载
- (instancetype)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmediately:(BOOL)startImmediately;
- (instancetype)initWithRequest:(NSURLRequest *)request delegate:(id)delegate; 这个要用 start 方法才开始
+ (NSURLConnection*)connectionWithRequest:(NSURLRequest *)request delegate:(id)delegate;
设置的delegate对象要实现协议<NSURLConnectionDataDelegate>
常用协议方法:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;

7.协议
+ (id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error;
XML是字符串,解析后是一个字典。

@property (nonatomic, retain) UIView *tableHeaderView;
@property (nonatomic, retain) UIView *tableFooterView;
UIView *headerview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 10)]; 只有高度值设置才有效
//设置section头部和尾部的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
//设置section头部和尾部样子
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
//设置section头部和尾部的标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;

浙公网安备 33010602011771号