好程序员-ios开发小知识点(二)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

16、程序启动画面大小iOS设备现在有三种不同的分辨率:iPhone320x480、iPhone4640x960、iPad768x1024。以前程序的启动画面(图片)只要准备一个Default.png就可以了,但是现在变得复杂多了。下面就是CocoaChina会员做得总结如果一个程序,既支持iPhone又支持iPad,那么它需要包含下面几个图片:Default-Portrait.pngiPad专用竖向启动画面768x1024或者768x1004Default-Landscape.pngiPad专用横向启动画面1024x768或者1024x748Default-PortraitUpsideDown.pngiPad专用竖向启动画面(Home按钮在屏幕上面),可省略768x1024或者768x1004Default-LandscapeLeft.pngiPad专用横向启动画面,可省略1024x768或者1024x748Default-LandscapeRight.pngiPad专用横向启动画面,可省略1024x768或者1024x748Default.pngiPhone默认启动图片,如果没有提供上面几个iPad专用启动图片,则在iPad上运行时也使用Default.png(不推荐)320x480或者320x460Default@2x.pngiPhone4启动图片640x960或者640x920为了在iPad上使用上述的启动画面,你还需要在info.plist中加入key:UISupportedInterfaceOrientations。同时,加入值UIInterfaceOrientationPortrait,UIInterfacOrientationPortraitUpsideDown,UIInterfaceOrientationLandscapeLeft,UIInterfaceOrientationLandscapeRight17、ASIHTTPRequest实现断点下载-(IBAction)URLFetchWithProgress:(id)sender{[startButtonsetTitle:@StopforState:UIControlStateNormal];[startButtonaddTarget:selfaction:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];NSString*tempFile=[[[[NSBundlemainBundle]bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@MemexTrails_1.0b1.zip.download];if([[NSFileManagerdefaultManager]fileExistsAtPath:tempFile]){[[NSFileManagerdefaultManager]removeItemAtPath:tempFileerror:nil];}[selfresumeURLFetchWithProgress:self];}-(IBAction)stopURLFetchWithProgress:(id)sender{networkQueue=[[ASINetworkQueuealloc]init];timer=[NSTimerscheduledTimerWithTimeInterval:1.0target:selfselector:@selector(updateBandwidthUsageIndicator)userInfo:nilrepeats:YES];timer=nil;[startButtonsetTitle:@StopforState:UIControlStateNormal];[startButtonaddTarget:selfaction:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];[networkQueuecancelAllOperations];[resumeButtonsetEnabled:YES];}-(IBAction)resumeURLFetchWithProgress:(id)sender{[resumeButtonsetEnabled:NO];[startButtonsetTitle:@StartforState:UIControlStateNormal];[startButtonaddTarget:selfaction:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];[networkQueuecancelAllOperations];[networkQueuesetShowAccurateProgress:YES];[networkQueuesetDownloadProgressDelegate:progressIndicator];[networkQueuesetDelegate:self];[networkQueuesetRequestDidFinishSelector:@selector(URLFetchWithProgressComplete:)];ASIHTTPRequest*request=[[[ASIHTTPRequestalloc]initWithURL:[NSURLURLWithString:@]]autorelease];[requestsetDownloadDestinationPath:[[[[NSBundlemainBundle]bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@MemexTrails_1.0b1.mp3]];[requestsetTemporaryFileDownloadPath:[[[[NSBundlemainBundle]bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@MemexTrails_1.0b1.zip.down]];[requestsetAllowResumeForFileDownloads:YES];[networkQueueaddOperation:request];[networkQueuego];}-(void)URLFetchWithProgressComplete:(ASIHTTPRequest*)request{if([requesterror]){fileLocation.text=[NSStringstringWithFormat:@Anerroroccurred:%@,[[[requesterror]userInfo]objectForKey:@Title]];}else{fileLocation.text=[NSStringstringWithFormat:@Filedownloadedto%@,[requestdownloadDestinationPath]];}[startButtonsetTitle:@StartforState:UIControlStateNormal];[startButtonaddTarget:selfaction:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];}-(IBAction)throttleBandwidth:(id)sender{if([(UIButton*)senderstate]==YES){[ASIHTTPRequestsetMaxBandwidthPerSecond:ASIWWANBandwidthThrottleAmount];}else{[ASIHTTPRequestsetMaxBandwidthPerSecond:];}}18、Safari启动本地app在plist文件中加入URLtypes结构如下图,在Safari中地址栏输入设置的字符串,比如设置的是QQ,地址栏输入QQ://就可以起点本地应用。19、拖到视频进度与滑动手势冲突解决办法#pragmamark-#pragmamarkUIGestureRecognizerDelegate-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizershouldReceiveTouch:(UITouch*)touch{UIView*touchView=touch.view;if([touchViewisKindOfClass:[UISliderclass]]){returnNO;}else{returnYES;}}20、创建并保存Cookie的方法NSString*cookieString=[NSStringstringWithString:[headersobjectForKey:@Cookie]];NSMutableDictionary*cookieProperties=[[NSMutableDictionaryalloc]init];[cookiePropertiessetValue:cookieStringforKey:NSHTTPCookieValue];[cookiePropertiessetValue:@QQCookieforKey:NSHTTPCookieName];[cookiePropertiessetValue:@.QQ.comforKey:NSHTTPCookieDomain];[cookiePropertiessetValue:[NSDatedateWithTimeIntervalSinceNow:60*60]forKey:NSHTTPCookieExpires];[cookiePropertiessetValue:@/forKey:NSHTTPCookiePath];NSHTTPCookie*newcookie=[[NSHTTPCookiealloc]initWithProperties:cookieProperties];[[NSHTTPCookieStoragesharedHTTPCookieStorage]setCookie:newcookie];21、popover横竖屏位置改变解决办法1、delegate中处理-(void)popoverControllerDidDismissPopover:(UIPopoverController*)popoverController{userImageShow=NO;if([popoverControllerisEqual:myPopover]){[myPopoverrelease];myPopover=nil;}}2、屏幕旋转时重新弹出Popoverif(myPopover){if((self.interfaceOrientation==UIInterfaceOrientationLandscapeLeft)||(self.interfaceOrientation==UIInterfaceOrientationLandscapeRight)){[myPopoverpresentPopoverFromRect:CGRectMake(10,180,1,1)inView:self.

1 / 21
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功