IOS中常用的知识总结(二)

116、程序启动画面大小 2  3 iOS设备现在有三种不同的分辨率:iPhone 320x480、iPhone 4 640x960、iPad 768x1024。以前程序的启动画面(图片)只要准备一个 Default.png 就可以了,但是现在变得复杂多了。下面就是 CocoaChina 会员做得总结 4  5  如果一个程序,既支持iPhone又支持iPad,那么它需要包含下面几个图片: 6  7Default-Portrait.png iPad专用竖向启动画面 768x1024或者768x1004 8  9Default-Landscape.png iPad专用横向启动画面 1024x768或者1024x748 10  11Default-PortraitUpsideDown.png iPad专用竖向启动画面(Home按钮在屏幕上面),可省略 768x1024或者768x1004 12  13Default-LandscapeLeft.png iPad专用横向启动画面,可省略 1024x768或者1024x748 14  15Default-LandscapeRight.png iPad专用横向启动画面,可省略 1024x768或者1024x748 16  17Default.png iPhone默认启动图片,如果没有提供上面几个iPad专用启动图片,则在iPad上运行时也使用Default.png(不推荐) 320x480或者320x460 18  19Default@2x.png iPhone4启动图片640x960或者640x920 20  21  为了在iPad上使用上述的启动画面,你还需要在info.plist中加入key: UISupportedInterfaceOrientations。同时,加入值UIInterfaceOrientationPortrait, UIInterfacOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight 22  2317、ASIHTTPRequest实现断点下载 24  25- (IBAction)URLFetchWithProgress:(id)sender 26  27{ 28  29[startButton setTitle:@"Stop" forState:UIControlStateNormal]; 30  31[startButton addTarget:self action:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; 32  33NSString*tempFile = [[[[NSBundle mainBundle] bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip.download"]; 34  35if ([[NSFileManager defaultManager] fileExistsAtPath:tempFile]) { 36  37[[NSFileManager defaultManager] removeItemAtPath:tempFile error:nil]; 38  39} 40  41[self resumeURLFetchWithProgress:self]; 42  43} 44  45- (IBAction)stopURLFetchWithProgress:(id)sender 46  47{ 48  49networkQueue = [[ASINetworkQueue alloc] init]; 50  51timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:selfselector:@selector(updateBandwidthUsageIndicator) userInfo:nil repeats:YES]; 52  53timer = nil; 54  55[startButton setTitle:@"Stop" forState:UIControlStateNormal]; 56  57[startButton addTarget:self action:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; 58  59[networkQueue cancelAllOperations]; 60  61[resumeButton setEnabled:YES]; 62  63} 64  65- (IBAction)resumeURLFetchWithProgress:(id)sender  66  67{ 68  69[resumeButton setEnabled:NO]; 70  71[startButton setTitle:@"Start" forState:UIControlStateNormal]; 72  73 [startButton addTarget:self action:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; 74  75[networkQueue cancelAllOperations]; 76  77[networkQueue setShowAccurateProgress:YES]; 78  79[networkQueue setDownloadProgressDelegate:progressIndicator]; 80  81[networkQueue setDelegate:self]; 82  83[networkQueue setRequestDidFinishSelector:@selector(URLFetchWithProgressComplete:)]; 84  85ASIHTTPRequest*request=[[[ASIHTTPRequest alloc] initWithURL:[NSURLURLWithString:@"http://9991.net/blog/mp3/2.mp3"]] autorelease]; 86  87[request setDownloadDestinationPath:[[[[NSBundle mainBundle] bundlePath] 88  89stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MemexTrails_1.0b1.mp3"]]; 90  91[request setTemporaryFileDownloadPath:[[[[NSBundle mainBundle] bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip.down"]]; 92  93[request setAllowResumeForFileDownloads:YES]; 94  95[networkQueue addOperation:request]; 96  97[networkQueue go]; 98  99} 100  101- (void)URLFetchWithProgressComplete:(ASIHTTPRequest *)request 102  103{ 104  105if ([request error]) { 106  107fileLocation.text=[NSString stringWithFormat:@"An error occurred:%@",[[[requesterror] userInfo] objectForKey:@"Title"]]; 108  109} else { 110  111fileLocation.text=[NSString stringWithFormat:@"File downloaded to %@",[requestdownloadDestinationPath]]; 112  113} 114  115[startButton setTitle:@"Start" forState:UIControlStateNormal]; 116  117[startButton addTarget:self action:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; 118  119} 120  121- (IBAction)throttleBandwidth:(id)sender 122  123{ 124  125if ([(UIButton *)sender state] ==YES) { 126  127[ASIHTTPRequest setMaxBandwidthPerSecond:ASIWWANBandwidthThrottleAmount]; 128  129} else { 130  131[ASIHTTPRequest setMaxBandwidthPerSecond:]; 132  133} 134  135} 136  13718、Safari 启动本地app 138  139在plist文件中加入URL types 结构如下图,在Safari中地址栏输入 设置的字符串,比如设置的是 140  141QQ,地址栏输入 QQ:// 就可以起点本地应用。 142  143   144  145  14619、拖到视频进度与滑动手势冲突解决办法 147  148#pragma mark - 149#pragma mark UIGestureRecognizerDelegate 150  151- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch 152{ 153    UIView *touchView = touch.view; 154      155    if ([touchView isKindOfClass:[UISlider class]])  156    { 157        return NO; 158    } 159    else 160    { 161        return YES; 162    } 163} 164  16520、创建并保存Cookie的方法 166  167  168        NSString *cookieString = [NSString stringWithString:[headers objectForKey:@"Cookie"]]; 169          170        NSMutableDictionary *cookieProperties = [[NSMutableDictionary alloc] init]; 171        [cookieProperties setValue:cookieString forKey:NSHTTPCookieValue]; 172        [cookieProperties setValue:@"QQCookie" forKey:NSHTTPCookieName]; 173        [cookieProperties setValue:@".QQ.com" forKey:NSHTTPCookieDomain]; 174        [cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60] forKey:NSHTTPCookieExpires]; 175        [cookieProperties setValue:@"/" forKey:NSHTTPCookiePath]; 176        NSHTTPCookie *newcookie = [[NSHTTPCookie alloc] initWithProperties:cookieProperties]; 177          178        [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newcookie]; 179  180  18121、popover横竖屏位置改变解决办法 182  1831、 delegate中 处理 184  185- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController 186{ 187    userImageShow = NO; 188      189    if ([popoverController isEqual:myPopover])  190    { 191        [myPopover release]; 192        myPopover = nil; 193    } 194} 195  1962、屏幕旋转时重新弹出Popover 197  198if (myPopover)   199  200{ 201  202     if ((self.interfaceOrientation ==  203       UIInterfaceOrientationLandscapeLeft) || (self.interfaceOrientation ==  204       UIInterfaceOrientationLandscapeRight))  205     { 206            [myPopover presentPopoverFromRect:CGRectMake(10,180, 1, 1) 207                                                inView:self.view 208                              permittedArrowDirections:UIPopoverArrowDirectionRight 209                                              animated:YES]; 210     } 211     else 212     { 213           [myPopover presentPopoverFromRect:CGRectMake(20,180, 1, 1) 214                                                inView:self.view 215                              permittedArrowDirections:UIPopoverArrowDirectionRight 216                                              animated:YES]; 217      } 218  219} 220  22122、plist各种key值含义 222  223原文:http://www.minroad.com/?p=434 224  225  226  227UIRequiresPersistentWiFi 在程序中弹出wifi选择的key(系统设置中需要将wifi提示打开) 228UIAppFonts 内嵌字体(http://www.minroad.com/?p=412 有详细介绍) 229UIApplicationExitsOnSuspend 程序是否在后台运行,自己在进入后台的时候exit(0)是很傻的办法 230UIBackgroundModes 后台运行时的服务,具体看iOS4的后台介绍 231UIDeviceFamily array类型(1为iPhone和iPod touch设备,2为iPad) 232UIFileSharingEnabled 开启itunes共享document文件夹 233UILaunchImageFile 相当于Default.png(更名而已) 234UIPrerenderedIcon icon上是否有高光 235UIRequiredDeviceCapabilities 设备需要的功能(具体点击这里查看) 236UIStatusBarHidden 状态栏隐藏(和程序内的区别是在于显示Default.png已经生效) 237UIStatusBarStyle 状态栏类型 238UIViewEdgeAntialiasing 是否开启抗锯齿 239CFBundleDisplayName app显示名 240CFBundleIconFile、CFBundleIconFiles 图标 241CFBundleName 与CFBundleDisplayName的区别在于这个是短名,16字符之内 242CFBundleVersion 版本 243CFBundleURLTypes 自定义url,用于利用url弹回程序 244CFBundleLocalizations 本地资源的本地化语言,用于itunes页面左下角显示本地话语种 245CFBundleDevelopmentRegion 也是本地化相关,如果用户所在地没有相应的语言资源,则用这个key的value来作为默认 246最后附上官方文档,所有的key都有,看英文原版才是正路:)点我进入
点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

10个必需的iOS开发工具和资源

转自:http://coolshell.cn/articles/5089.html界面总不是一件很容易事,尤其是iPhone/iPad的界面,做过iOS开发的程序员,一定会感到开发iPhone/iPad的界面是一件多么不容易的事。下面的文章来自10EssentialiOSDeveloperTools&Resources(https://w

Aiseesoft iPhone Unlocker mac Aiseesoft iPhone Unlocker 中文

AiseesoftiPhoneUnlocker一款功能强大、易于操作、安全可靠的iOS设备解锁工具,为用户提供了一个方便快捷的解决方案。iPhone屏幕锁定?立即擦除iPhone密码为iPhone创建密码可以保护您的隐私。但是,您无法控制锁屏密码的原因有很

iOS数据恢复工具:PhoneRescue for Mac中文版

是一款终极的iOS数据恢复程序,设计用于在iPhone、iPad和iPodtouch上检索丢失的数据,包括照片、消息、联系人、便笺等,同时也可以从任何iOS崩溃错误修复iDevice。这款软件可以恢复设备上丢失的数据,包括从设备、iTunes备份和iClo

HTTP协议抓包工具:Charles for Mac

是一款终极的iOS数据恢复程序,设计用于在iPhone、iPad和iPodtouch上检索丢失的数据,包括照片、消息、联系人、便笺等,同时也可以从任何iOS崩溃错误修复iDevice。这款软件可以恢复设备上丢失的数据,包括从设备、iTunes备份和iClo

邮件管理工具:Outlook LTSC 2021 for Mac中文版

是一款终极的iOS数据恢复程序,设计用于在iPhone、iPad和iPodtouch上检索丢失的数据,包括照片、消息、联系人、便笺等,同时也可以从任何iOS崩溃错误修复iDevice。这款软件可以恢复设备上丢失的数据,包括从设备、iTunes备份和iClo