0718 -- 0728 webview/博客园资料/多线程/网络请求不同方式/导航栏外观设置

来源:互联网 发布:贝叶斯网络训练 编辑:程序博客网 时间:2024/04/29 17:04

1.webView中的几个属性

    1.@property(nonatomic) BOOL allowsInlineMediaPlayback  

默认使NO。这个值决定了用内嵌HTML5播放视频还是用本地的全屏控制。
为了内嵌视频播放,不仅仅需要在这个页面上设置这个属性,还必须的是在HTML中的video元素必须包含webkit-playsinline属性。

    2.@property(nonatomic) BOOL mediaPlaybackRequiresUserAction  

在iPhone和iPad上默认使YES。这个值决定了HTML5视频可以自动播放还是需要用户去启动播放

    3.@property(nonatomic) BOOL mediaPlaybackAllowsAirPlay  

这个值决定了从这个页面是否可以Air Play。

webview详解 一篇博客地址
http://blog.csdn.net/lixuwen521/article/details/9293257

  1. 新浪微博API 错误代码对照表的一篇文章地址
    http://blog.unvs.cn/archives/sina-api-error-code.html

    2.一个博客园博主
    博客内容
    http://www.cnblogs.com/ygm900/
    3 .iOS8新特性 UIPresentationController 介绍使用
    http://www.15yan.com/story/jlkJnPmVGzc/
    4.在iOS 8中使用UIAlertController 详细介绍
    http://www.cocoachina.com/ios/20141126/10320.html
    5.多线程介绍
    http://www.jianshu.com/p/0b0d9b1f1f19
    另一篇 http://www.jianshu.com/p/9e41f828c50c

    1. OS开发网络篇—GET请求和POST请求
      http://www.cnblogs.com/wendingding/p/3813706.html
      http://www.cnblogs.com/qiqibo/archive/2012/09/03/2669371.html
      http://blog.csdn.net/heyddo/article/details/37561005
    2. 网络请求NSURLSession代替NSConnection
      http://www.jianshu.com/p/fafc67475c73
      http://www.cnphp6.com/archives/64928
      8.storyboard或者xib中,添加没有其中选项里没有的属性设置方法,
      以给button设置圆角为例
      http://www.bubuko.com/infodetail-588175.html
      9.动态修改UINavigationBar的背景色
      http://www.cocoachina.com/ios/20150409/11505.html
    3. get请求 NSURLSession 方法发送
// 快捷方式获得session对象    NSURLSession *session = [NSURLSession sharedSession];    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://ued.ijntv.cn/zwapp/login.php?username=%@&password=%@",self.userNameTextField.text,self.passwordTextField.text] ];    // 通过URL初始化task,在block内部可以直接对返回的数据进行处理    NSURLSessionTask *task = [session dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {        if (error) {            NSLog(@"请求失败%@",error);        }else {            NSLog(@"登录请求成功%@", [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]);            //NSLog(@"%@",data);        }    }];    // 启动任务    [task resume];

11.post请求

 //设置请求路径    NSURL *urlPost = [NSURL URLWithString:@"http://ued.ijntv.cn/zwapp/login.php"];    //创建请求对象    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlPost];    //设置请求超时    request.timeoutInterval = 5.0;    request.HTTPMethod = @"POST";    //设置请求体 拼接要提交的参数    NSString *parameter = [NSString stringWithFormat:@"username=%@&password=%@",self.userNameTextField.text,self.passwordTextField.text];    //拼接后字符串转为data,设置请求体    NSData *bodyData = [parameter dataUsingEncoding:NSUTF8StringEncoding];    //把参数添加到请求中    request.HTTPBody = bodyData;    [request setValue:@"ios+android" forHTTPHeaderField:@"User-Agent"];

//发送请求

NSURLSession *session = [NSURLSession sharedSession];    NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {        if (error) {            NSLog(@"请求出现错误%@",error);        }else {        //   NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];            NSLog(@"正确请求结果 原因--%@ 结果--%@ 信息--%@",dict[@"reason"],dict[@"state"],dict[@"userinfo"]);            NSLog(@"-----%@",dict);            //登录成功后页面跳转            if ([dict[@"state"] isEqualToString:@"success"]) {                dispatch_async(dispatch_get_main_queue(), ^{//在主线程中更新UI                  //跳转到登录详情页面                    MemberCenterViewController *memberVC = [[MemberCenterViewController alloc]initWithNibName:@"MemberCenter" bundle:nil];                    memberVC.nameLabelString = dict[@"userinfo"][@"phone"];                    //[self presentViewController:memberVC animated:YES completion:nil];                    [self.navigationController pushViewController:memberVC animated:YES];                    NSLog(@"-----%@",dict[@"userinfo"][@"phone"]);                    NSLog(@"label---%@",memberVC.nameLabelString);                });            }        }    }];    [task resume];

//session 发送请求第二种方法, 使用代理方法的 需要遵守

 // 使用代理方法需要设置代理,但是session的delegate属性是只读的,要想设置代理只能通过这种方式创建session    NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]                                                          delegate:self                                                     delegateQueue:[[NSOperationQueue alloc] init]];    // 创建任务(因为要使用代理方法,就不需要block方式的初始化了)    NSURLSessionDataTask *task = [session dataTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:parameter]]];    // 启动任务    [task resume];

//监测这种请求方式的代理方法

- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler {    completionHandler(NSURLSessionResponseAllow);    NSLog(@"接收到服务器相应");}-(void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data {    NSLog(@"处理每次接收的数据");}-(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error {    if (error) {        NSLog(@"失败 %@",error);    }else {        NSLog(@"成功");    }}

//另外,已被遗弃的NSConnection发送请求的方法

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {        NSError *error;        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingAllowFragments) error:&error];        if (error) {            NSLog(@"请求出现错误 %@",[error localizedDescription]);        }        NSLog(@"请求结果:%@",dic);    }];

//AFNetworking 发送post的方法

#import "AFNetworking.h"#import "UIKit+AFNetworking.h"#import "AFURLResponseSerialization.h"NSString *userName = self.userNameTextField.text;    NSString *password = self.passwordTextField.text;    //请求的参数,即向服务器发送的参数    NSDictionary *parameters = @{@"username":userName,@"password":password};    //请求的网址,即请求的接口    NSString *urlString = @"http://ued.ijntv.cn/zwapp/login";    //请求的manager    AFHTTPSessionManager *managers = [AFHTTPSessionManager manager];    managers.responseSerializer = [AFHTTPResponseSerializer serializer];/////这是特殊设置,接口类型返回值不确定时    //请求的方式 post    [managers POST:urlString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {        //NSDictionary *backdata = responseObject;        NSData *data = responseObject;        NSError *err;      //  NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];        NSDictionary *dit = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&err];        NSLog(@"请求成功,服务器返回的信息 %@",[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]);    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {        NSLog(@"请求失败,服务器返回的错误信息%@",error);    }];
  1. 基于AFNetworking3.0网络封装
    HYBNetWorking
  2. 自定义iOS7导航栏背景,标题和返回按钮文字颜色
    http://blog.csdn.net/mad1989/article/details/41516743
0 0
原创粉丝点击