首页 文章 精选 留言 我的

精选列表

搜索[ios],共10000篇文章
优秀的个人博客,低调大师

iOS开发之iPhone通过get和post方式请求asp.net webservice

这篇文章,我将通过一个简单的例子来展现iPhone通过get和post方式请求asp.net webservice。 webservice 1、创建一个webservice 2、在webconfig中启用http get 和http post。 < webServices > < protocols > < add name ="HttpSoap" /> < add name ="HttpPost" /> < add name ="HttpGet" /> < add name ="Documentation" /> </ protocols > </ webServices > iphone客户端调用: 1、get的方式: NSString * queryString = [NSStringstringWithFormat: @“http: // 10.5.23.117:5111/Service1.asmx/HelloWorld?param=123%@“, ipAddress.text]; NSURL * url = [NSURLURLWithString:queryString]; NSMutableURLRequest * req = [NSMutableURLRequestrequestWithURL:url]; [reqaddValue:@“text / xml;charset = utf - 8 ”forHTTPHeaderField:@“Content - Type”]; [reqaddValue: 0 forHTTPHeaderField:@“Content - Length”]; [reqsetHTTPMethod:@“GET”]; [activityIndicatorstartAnimating]; conn = [[NSURLConnectionalloc]initWithRequest:req delegate :self]; if (conn){ webData = [[NSMutableDatadata]retain]; } 2、post的方式: NSString *postString =@ "123" ; NSURL *url = [ NSURL URLWithString: @“http: //10.5.23.117:5111/Service1.asmx/HelloWorld2”]; NSMutableURLRequest *req = [ NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [ NSString stringWithFormat:@“%d”, [postString length]]; [req addValue:@“application/x-www-form-urlencoded” forHTTPHeaderField:@“Content-Type”]; [req addValue:msgLength forHTTPHeaderField:@“Content-Length”]; [req setHTTPMethod:@“POST”]; [req setHTTPBody: [postString dataUsingEncoding: NSUTF8StringEncoding ]]; [activityIndicator startAnimating]; conn = [[ NSURLConnection alloc] initWithRequest:req delegate: self ]; if (conn) { webData = [[ NSMutableData data] retain]; } 本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2011/07/13/2105640.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

解读阿里云oss-android/ios-sdk 断点续传(多线程)

前言 移动端现状随着移动端设备的硬件水平的不断提高,如今的cpu,内存等方面都大大的超过了一般的pc电脑,因此在现今的程序中,合理的使用多线程去完成一些事情是非常有必要的。 多线程上传的好处 进一步占满网络资源。 进一步占满I/O资源。 实现原理 策略oss有分片上传的功能,阿里云断点续传就是基于分片上传的几个api接口进行的封装,主要由InitiateMultipartUpload,UploadPart,CompleteMultipartUpload,AbortMultipartUpload,ListParts这几个组成。 流程 细节 断点续传是一个大任务,又3部分来完成,分别是获取uploadId,分片上传,完成上传,这一整个连续的步骤统一在一个线程中进行。 获取uploadId这块需要先对本地缓存文件进行获取,如未拿到,就会直接重新生成新的up

优秀的个人博客,低调大师

[IOS]UIWebView实现保存页面和读取服务器端json数据

如何通过viewView保存访问过的页面?和如何获取并解析服务器端发送过来的json数据?通过一个简单的Demo来学习一下吧! 操作步骤: 1.创建SingleViewApplication应用,新建VIewController,并在xib试图中添加WebView,继承webview的Delegate协议。 2.将ViewController类遵循UIWebViewDelegate和NSURLConnectionDataDelegate协议,并且实现协议中的方法。 ViewController.h: #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIWebViewDelegate,NSURLConnectionDataDelegate> @property (retain, nonatomic) IBOutlet UIWebView *webview; @property (retain, nonatomic) UIAlertView * alert; @property (retain, nonatomic) IBOutlet UITextField *searchText; - (IBAction)searchClick:(id)sender; @property (retain, nonatomic) IBOutlet UILabel *label; @property (retain, nonatomic) NSURLConnection * connection; @property (retain, nonatomic) NSMutableData * data; @end VIewController.m: #import"ViewController.h" @interfaceViewController() @end @implementationViewController - (void)viewDidLoad { [superviewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //请求网络页面 // NSURL * url = [NSURL URLWithString:@"http://www.taobao.com"]; //一定要加http:// // NSURLRequest * request = [NSURLRequest requestWithURL:url]; // [self.webview loadRequest:request]; // // // //html加载本地网页 // NSString * str = [[NSBundle mainBundle] pathForResource:@"百度图片—全球最大中文图片库" ofType:@"html"]; // str = [NSString stringWithContentsOfFile:str encoding:NSUTF8StringEncoding error:nil]; // NSLog(@"%@",str); // [self.webview loadHTMLString:str baseURL:[[NSBundle mainBundle]bundleURL]]; // self.label.text=@"正在请求数据"; //step1:请求地址 //保存页面 //NSString * urlString = @"http://www.baidu.com"; //访问服务器获取json数据 NSString* urlString =@"http://www.weather.com.cn/data/cityinfo/101020100.html"; NSURL* url = [NSURLURLWithString:urlString]; //step2:实例化一个request NSURLRequest* request = [NSURLRequestrequestWithURL:urlcachePolicy:NSURLRequestUseProtocolCachePolicytimeoutInterval:30.0]; //step3:创建链接 self.connection= [[NSURLConnectionalloc]initWithRequest:requestdelegate:self]; if(self.connection) { NSLog(@"创建链接成功"); }else{ NSLog(@"创建链接失败"); } [urlrelease]; [urlStringrelease]; } - (void)didReceiveMemoryWarning { [superdidReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)dealloc { [_webviewrelease]; [_searchTextrelease]; [_labelrelease]; [superdealloc]; } //获取数据 -(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response { //接受一个服务端回话,再次一般初始化接受数据的对象 //NSLog(@"返回数据类型%@",[response ]); //NSLog(@"返回数据编码%@",[response text]); NSMutableData* data = [[NSMutableDataalloc]init]; self.data= data; [datarelease]; } //不断的获取数据 -(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data { //接受返回数据,这个方法可能会被调用多次,因此将多次返回数据加起来 NSIntegerdatalength = [datalength]; NSLog(@"返回数据量:%d",datalength); [self.dataappendData:data]; } //获取文件地址 -(NSString*)dataFilePath:(NSString*)fileName { NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString*document=[pathsobjectAtIndex:0]; return[documentstringByAppendingPathComponent:fileName]; } -(void)connectionDidFinishLoading:(NSURLConnection*)connection { // //连接结束 NSLog(@"%d",[self.datalength]); self.label.text=@"请求结束"; //可以下载图片 //[self.data writeToFile:[self dataFilePath:@"image.jpg"] atomically:YES]; NSString* mystr = [[NSStringalloc]initWithData:self.dataencoding:NSUTF8StringEncoding]; [mystrwriteToFile:[selfdataFilePath:@"百度图片—全球最大中文图片库.html"] atomically:YESencoding:NSUTF8StringEncodingerror:nil]; NSLog(@"最后的结果%@",mystr); [mystrrelease]; // NSDictionary *weather = [NSJSONSerialization JSONObjectWithData:self.data options:NSJSONReadingMutableContainers error:nil]; // NSLog(@"%@",weather); // [weather writeToFile:[self dataFilePath:@"weather.plist"] atomically:YES]; } -(void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error { self.label.text=@"连接失败"; } - (IBAction)searchClick:(id)sender { } @end 结果: 2013-08-27 16:09:18.821 WebViewDemo[673:c07]创建链接成功 2013-08-27 16:09:19.161 WebViewDemo[673:c07]返回数据量:153 2013-08-27 16:09:19.161 WebViewDemo[673:c07] 153 2013-08-27 16:09:19.193 WebViewDemo[673:c07]最后的结果{"weatherinfo":{"city":"上海","cityid":"101020100","temp1":"32℃","temp2":"27℃","weather":"多云","img1":"d1.gif","img2":"n1.gif","ptime":"11:00"}} ==================== 迂者 丁小未 CSDN博客专栏================= MyBlog:http://blog.csdn.net/dingxiaowei2013 MyQQ:1213250243 Unity QQ群:858550 cocos2dx QQ群:280818155 ======================相互学习,共同进步=================== 转载请注明出处:http://blog.csdn.net/dingxiaowei2013/article/details/10399799 欢迎关注我的微博: http://weibo.com/u/2590571922 本文转蓬莱仙羽51CTO博客,原文链接:http://blog.51cto.com/dingxiaowei/1366416,如需转载请自行联系原作者

优秀的个人博客,低调大师

【转】IOS数据持久化三个方法:plist、sqlite3、Archiver

1、plist 局限性:只有它支持的数据类型可以被序列化,存储到plist中。无法将其他Cocoa对象存储到plist,更不能将自定义对象存储。 支持的数据类型:Array,Dictionary,Boolean,Data,Date,Number和String. xml文件 数据类型截图~其中基本数据(Boolean,Data,Date,Number和String.)、容器 (Array,Dictionary) 写入xml过程:先将基本数据写入容器 再调用容器的 writeToFile 方法,写入。 [theArray writeToFile:filePath atomically:YES]; 拥有此方法的数据类型有: atomically参数,将值设置为 YES。写入文件的时候,将不会直接写入指定路径,而是将数据写入到一个“辅助文件”,写入成功后,再将其复制到指定路径。 2、Archiver 特点:支持复杂的数据对象。包括自定义对象。对自定义对象进行归档处理,对象中的属性需满足:为基本数据类型(int or float or......),或者为实现了NSCoding协议的类的实例。自定义对象的类也需要实现NSCoding。 NSCoding 方法:-(id)initWithCoder:(NSCoder *)decoder; - (void)encodeWithCoder:(NSCoder *)encoder; 参数分别理解为解码者和编码者。 例如创建自定义类Student:NSObject <NSCoding> 1 #import " Student.h " 2 3 4 @implementation Student 5 @synthesize studentID; 6 @synthesize studentName; 7 @synthesize age; 8 @synthesize count; 9 10 - ( void )encodeWithCoder:(NSCoder * )encoder 11 { 12 [encoder encodeObject: studentID forKey: kStudentId]; 13 [encoder encodeObject: studentName forKey: kStudentName]; 14 [encoder encodeObject: age forKey: kAge]; 15 [encoder encodeInt:count forKey:kCount]; 17 } 18 19 - (id)initWithCoder:(NSCoder * )decoder 20 { 21 if (self == [super init]) { 22 self.studentID = [decoder decodeObjectForKey:kStudentId]; 23 self.studentName = [decoder decodeObjectForKey:kStudentName]; 24 self.age = [decoder decodeObjectForKey:kAge]; 25 self.count = [decoder decodeIntForKey:kCount]; 27 } 28 return self; 29 } 30 31 @end 编码过程: 1 /* encoding */ 2 Student * theStudent = [[Student alloc] init]; 3 theStudent.studentID = @" 神马 " ; 4 theStudent.studentName = @" shenma " ; 5 theStudent.age = @" 12 " ; 6 7 NSMutableData * data = [[NSMutableData alloc] init]; 8 NSKeyedArchiver * archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; 9 10 [archiver encodeObject: theStudent forKey: @" student " ]; NSKeyedArchiver可以看作“加密器”,将student实例编码后存储到data NSMutableData 可看作“容器”,并由它来完成写入文件操作(inherits NSData)。 解码过程: 1 /* unencoding */ 2 Student * studento = [[Student alloc] init]; 3 data = [[NSData alloc] initWithContentsOfFile:documentsPath]; 4 NSKeyedUnarchiver * unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; 5 6 studento = [unarchiver decodeObjectForKey: @" student " ]; 7 [unarchiver finishDecoding]; 根据键值key得到反序列化后的实例。 3、SQLite 本文转自编程小翁博客园博客,原文链接:http://www.cnblogs.com/wengzilin/archive/2012/03/30/2424944.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

移动端图片上传方法【更好的兼容安卓IOS和微信】

之前的移动端上传的方法,有些朋友测试说微信支持不是很好,还有部分安卓机也不支持,其实我已经有了另一个方法,但是例子还没整理出来,而联系我的很多朋友需要,所以就提前先发出来了,并且做一个简单的说明,就不做一个demo了。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 <!doctypehtml> < html > < head > < meta charset = "utf-8" > < meta name = "viewport" content = "width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0" > < title >图片压缩</ title > < style > body{margin:0;padding:0;} html{font-size:62.5%;} .imgzip{padding:1em;} .imgzip.itm{padding-bottom:1em;word-break:break-all;font-size:1.2rem;line-height:1.5em;} .imgzip.itm.tit{margin-bottom:.5em;background-color:#e71446;color:#FFF;padding:.5rem1rem;border-radius:3px;} .imgzip.itm.cnt{padding:1rem;} .imgzip.itm.cntimg{display:block;max-width:100%;} .imgziptextarea{width:100%;height:20em;} </ style > </ head > < body > < script src = "http://code.jquery.com/jquery-1.8.3.js" ></ script > < input type = "file" accept = "image/*;capture=camera" class = "input" > < div class = "imgzip" ></ div > < script > document.addEventListener('DOMContentLoaded',init,false); functioninit(){ varu=newUploadPic(); u.init({ input:document.querySelector('.input'), callback:function(base64){ $.ajax({ url:"{:U('upload')}", data:{str:base64,type:this.fileType}, type:'post', dataType:'json', success:function(i){ alert(i.info); } }) }, loading:function(){ } }); } functionUploadPic(){ this.sw=0; this.sh=0; this.tw=0; this.th=0; this.scale=0; this.maxWidth=0; this.maxHeight=0; this.maxSize=0; this.fileSize=0; this.fileDate=null; this.fileType=''; this.fileName=''; this.input=null; this.canvas=null; this.mime={}; this.type=''; this.callback=function(){}; this.loading=function(){}; } UploadPic.prototype.init=function(options){ this.maxWidth=options.maxWidth||800; this.maxHeight=options.maxHeight||600; this.maxSize=options.maxSize||3*1024*1024; this.input=options.input; this.mime={'png':'image/png','jpg':'image/jpeg','jpeg':'image/jpeg','bmp':'image/bmp'}; this.callback=options.callback||function(){}; this.loading=options.loading||function(){}; this._addEvent(); }; /** *@description绑定事件 *@param{Object}elm元素 *@param{Function}fn绑定函数 */ UploadPic.prototype._addEvent=function(){ var_this=this; functiontmpSelectFile(ev){ _this._handelSelectFile(ev); } this.input.addEventListener('change',tmpSelectFile,false); }; /** *@description绑定事件 *@param{Object}elm元素 *@param{Function}fn绑定函数 */ UploadPic.prototype._handelSelectFile=function(ev){ varfile=ev.target.files[0]; this.type=file.type //如果没有文件类型,则通过后缀名判断(解决微信及360浏览器无法获取图片类型问题) if(!this.type){ this.type=this.mime[file.name.match(/\.([^\.]+)$/i)[1]]; } if(!/image.(png|jpg|jpeg|bmp)/.test(this.type)){ alert('选择的文件类型不是图片'); return; } if(file.size>this.maxSize){ alert('选择文件大于'+this.maxSize/1024/1024+'M,请重新选择'); return; } this.fileName=file.name; this.fileSize=file.size; this.fileType=this.type; this.fileDate=file.lastModifiedDate; this._readImage(file); }; /** *@description读取图片文件 *@param{Object}image图片文件 */ UploadPic.prototype._readImage=function(file){ var_this=this; functiontmpCreateImage(uri){ _this._createImage(uri); } this.loading(); this._getURI(file,tmpCreateImage); }; /** *@description通过文件获得URI *@param{Object}file文件 *@param{Function}callback回调函数,返回文件对应URI *return{Bool}返回false */ UploadPic.prototype._getURI=function(file,callback){ varreader=newFileReader(); var_this=this; functiontmpLoad(){ //头不带图片格式,需填写格式 varre=/^data:base64,/; varret=this.result+''; if(re.test(ret))ret=ret.replace(re,'data:'+_this.mime[_this.fileType]+';base64,'); callback&&callback(ret); } reader.onload=tmpLoad; reader.readAsDataURL(file); returnfalse; }; /** *@description创建图片 *@param{Object}image图片文件 */ UploadPic.prototype._createImage=function(uri){ varimg=newImage(); var_this=this; functiontmpLoad(){ _this._drawImage(this); } img.onload=tmpLoad; img.src=uri; }; /** *@description创建Canvas将图片画至其中,并获得压缩后的文件 *@param{Object}img图片文件 *@param{Number}width图片最大宽度 *@param{Number}height图片最大高度 *@param{Function}callback回调函数,参数为图片base64编码 *return{Object}返回压缩后的图片 */ UploadPic.prototype._drawImage=function(img,callback){ this.sw=img.width; this.sh=img.height; this.tw=img.width; this.th=img.height; this.scale=(this.tw/this.th).toFixed(2); if(this.sw>this.maxWidth){ this.sw=this.maxWidth; this.sh=Math.round(this.sw/this.scale); } if(this.sh>this.maxHeight){ this.sh=this.maxHeight; this.sw=Math.round(this.sh*this.scale); } this.canvas=document.createElement('canvas'); varctx=this.canvas.getContext('2d'); this.canvas.width=this.sw; this.canvas.height=this.sh; ctx.drawImage(img,0,0,img.width,img.height,0,0,this.sw,this.sh); this.callback(this.canvas.toDataURL(this.type)); ctx.clearRect(0,0,this.tw,this.th); this.canvas.width=0; this.canvas.height=0; this.canvas=null; }; </ script > </ body > </ html > 这个也是把图片转成了base64去传送,个人不建议去用js改变图片的大小,建议裁切缩放还是PHP来做吧。 1 2 3 4 5 this.maxWidth=options.maxWidth||800; this.maxHeight=options.maxHeight||600; this.maxSize=options.maxSize||3*1024*1024; this.input=options.input; this.mime={'png':'image/png','jpg':'image/jpeg','jpeg':'image/jpeg','bmp':'image/bmp'}; 这一部分是对上传图片的配置,应该可以看懂,可以自己去改 1 2 3 4 5 6 7 8 $.ajax({ url:"{:U('upload')}", data:{str:base64,type:this.fileType}, type:'post', dataType:'json', success:function(i){ alert(i.info); } 这部分是上传以后ajax发送base64码到php, base64码带有图片的说明字符串,所以得用正则去掉,然后base64解码保存到图片的文件中。并且返回地址即可 upload.php的内容 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 $str = $_POST [ 'str' ]; $type = $_POST [ 'type' ]; switch ( $type ){ case 'image/png' : $ext = '.png' ; break ; case 'image/jpeg' ; $ext = '.jpeg' ; break ; case 'image/jpeg' : $ext = '.jpg' ; break ; case 'image/bmp' : $ext = '.bmp' ; break ; default : $ext = '.jpg' ; } $file_path = './Uploads/' . date ( 'Ymd' ). '/' .time(). $ext ; if (! file_exists (dirname( $file_path ))){ mkdir (dirname( $file_path ),0777,true); } $img_content = str_replace ( 'data:' . $type . ';base64,' , '' , $str ); $img_content = base64_decode ( $img_content ); $result = file_put_contents ( $file_path , $img_content ); 本文转自 3147972 51CTO博客,原文链接:http://blog.51cto.com/a3147972/1554698,如需转载请自行联系原作者

优秀的个人博客,低调大师

【转】IOS屏幕旋转与View的transform属性之间的关系,比较底层

iTouch,iPhone,iPad设置都是支持旋转的,如果我们的程序能够根据不同的方向做出不同的布局,体验会更好。 如何设置程序支持旋转呢,通常我们会在程序的info.plist中进行设置Supported interface orientations,添加我们程序要支持的方向,而且程序里面每个viewController也有方法 supportedInterfaceOrientations(6.0及以后) shouldAutorotateToInterfaceOrientation(6.0之前的系统) 通过viewController的这些方法,我们可以做到更小粒度的旋转控制,如程序中仅仅允许个别界面旋转。 一、屏幕旋转背后到底做了什么呢? 下面我们看个简单的例子,用xcode新建一个默认的单视图工程,然后在对应viewController的响应旋转后的函数中输出一下当前view的信息,代码如下: View Code 查看代码我们可以发现,我们的viewController支持四个方向,然后在旋转完成的didRotateFromInterfaceOrientation函数中打印了self.view的信息,旋转一圈我们可以看到如下输出: 设备的初始方向是UIInterfaceOrientationPortrait的,然后顺时针依次经过LandscapeLeft,PortraitUpsideDown,LandscapeRight,最后再回到UIInterfaceOrientationPortrait方向。仔细看的话我们会发现在旋转的过程中,除了frame之外,Transform也在一直变化。观察frame发现,它的变化应该是由于系统的状态栏引起的。于是将系统状态栏隐藏掉,在输出发现frame果然不再变化。因此我们可以怀疑屏幕旋转是通过变化Transform实现的。 二、什么是Transform Transform(变化矩阵)是一种3×3的矩阵,如下图所示: 通过这个矩阵我们可以对一个坐标系统进行缩放,平移,旋转以及这两者的任意组着操作。而且矩阵的操作不具备交换律,即矩阵的操作的顺序不同会导致不同的结果。UIView有个transform的属性,通过设置该属性,我们可以实现调整该view在其superView中的大小和位置。 矩阵实现坐标变化背后的数学知识: 设x,y分别代表在原坐标系统中的位置,x',y'代表通过矩阵变化以后在新的系统中的位置。其中式1就是矩阵变化的公式,对式1进行展开以后就可以得到式2。从式2我们可以清楚的看到(x,y)到(x',y')的变化关系。 1)当c,b,tx,ty都为零时,x' = ax,y' = by;即a,d就分别代表代表x,y方向上放大的比例;当a,d都为1时,x' = x,y' = y;这个时候这个矩阵也就是传说中的CGAffineTransformIdentity(标准矩阵)。 2)当a,d为1,c,d为零的时候,x' = x + tx,y' = y + ty;即tx,ty分别代表x,y方向上的平移距离。 3)前面两种情况就可以实现缩放和平移了,那么旋转如何表示呢? 假设不做平移和缩放操作,那么从原坐标系中的一点(x,y)旋转α°以后到了新的坐标系中的一点(x',y'),那么旋转矩阵如下: 展开以后就是x' = xcosα - ysinα,y' = xsinα + ycosα; 实际应用中,我们将这些变化综合起来,即可完成所有二维的矩阵变化。现在我们在回过头来看看前面设备旋转时的输出,当设备位于Portrait的时候由于矩阵是标准矩阵,所以没有进行打印。当转到UIInterfaceOrientationLandscapeLeft方向的时候,我们的设备是顺时针转了90°,这个时候矩阵应该是(cos90°,sin90°,-sin90°,cos90°,tx,ty),由于未进行平移操作所以tx,ty都为0,刚好可以跟我们控制台输出:"<UIView: 0x8075390; frame = (0 0; 320 480); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x8074980>>"一致。观察其他两个方向的输出,发现结果均和分析一致。 由此可以发现屏幕旋转其实就是通过view的矩阵变化实现,当设备监测到旋转的时候,会通知当前程序,当前程序再通知程序中的window,window会通知它的rootViewController的,rootViewController对其view的transform进行设置,最终完成旋转。 如果我们直接将一个view添加到window上,系统将不会帮助我们完成旋操作,这个时候我们就需要自己设置该view的transform来实现旋转了。这种情况虽然比较少,但是也存在的,例如现在很多App做的利用状态栏进行消息提示的功能就是利用自己创建window并且自己设置transform来完成旋转支持的。 本文转自编程小翁博客园博客,原文链接:http://www.cnblogs.com/wengzilin/p/3258455.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS xcode jenkins 测试打包显示自增版本号及时间戳

测试部门要求打包能显示自增版本号或时间戳,以区别打包版本在测试手中的不同,好定位指定打包版本的问题。 在Xcode工程里选择对应的Target,在Build Phases里点击“New Run Script Phases”: 在下面的窗口中写入类似于如下脚本: 说明:workspace_dir 是workspace项目,project_dir是project项目。 1 2 3 4 5 6 7 buildNumber=$( /usr/libexec/PlistBuddy -c "Print:CFBundleVersion" "${WORKSPACE_DIR}/${INFOPLIST_FILE}" ) shortVersion=$( /usr/libexec/PlistBuddy -c "Print:CFBundleShortVersionString" "${WORKSPACE_DIR}/${INFOPLIST_FILE}" ) buildNumber=` date + "%m%d" ` buildNumber= "$shortVersion.$buildNumber" /usr/libexec/PlistBuddy -c "Set:CFBundleVersion$buildNumber" "${WORKSPACE_DIR}/${INFOPLIST_FILE}" 版本号加时间戳自增值。 这种做法对原应用介入太深,修改了系统plist的CFBundleVersion值。为了不影响原应用代码,在info.plist文件新增自定义新值CFBundelInfoDictionaryVersion,对其操作。 1 2 3 buildNumber=` date + "%Y%m%d%H%M" ` /usr/libexec/PlistBuddy -c "Set:CFBundleInfoDictionaryVersion$buildNumber" "${WORKSPACE_DIR}/${INFOPLIST_FILE}" 在版本显示部分代码 1 2 3 4 cell1.mainString=@ "内部版本" ; NSString*version1=[NSStringstringWithFormat:@ "%@" ,[[[NSBundlemainBundle]infoDictionary]objectForKey:@ "CFBundleInfoDictionaryVersion" ]]; cell1.detailString=version1; return cell1; 说明:date +"%Y%m%d%H%M%S" 年月日时分秒 格式。 plist文件路径写法,涉及xcode全局变量定义。 $(SRCROOT)/YouPinHui/SupportFile/Info.plist ${WORKSPACE_DIR}/${INFOPLIST_FILE} 如果仅仅只想在Release(如Archive等)的时候更新Build,可以加入判断: if["${CONFIGURATION}"="Release"];then fi 本文转自ljianbing51CTO博客,原文链接: http://blog.51cto.com/ljianbing/1745208,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码