16、程序启动画面大小 iOS设备现在有三种不同的分辨率:iPhone 320x480、iPhone 4 640x960、iPad 768x1024。以前程序的启动画面(图片)只要准备一个 Default.png 就可以了,但是现在变得复杂多了。下面就是 CocoaChina 会员做得总结 如果一个程序,既支持iPhone又支持iPad,那么它需要包含下面几个图片: Default-Portrait.png iPad专用竖向启动画面 768x1024或者768x1004 Default-Landscape.png iPad专用横向启动画面 1024x768或者1024x748 Default-PortraitUpsideDown.png iPad专用竖向启动画面(Home按钮在屏幕上面),可省略 768x1024或者768x1004 Default-LandscapeLeft.png iPad专用横向启动画面,可省略 1024x768或者1024x748 Default-LandscapeRight.png iPad专用横向启动画面,可省略 1024x768或者1024x748 Default.png iPhone默认启动图片,如果没有提供上面几个iPad专用启动图片,则在iPad上运行时也使用Default.png(不推荐) 320x480或者320x460 Default@2x.png iPhone4启动图片640x960或者640x920 为了在iPad上使用上述的启动画面,你还需要在info.plist中加入key: UISupportedInterfaceOrientations。同时,加入值UIInterfaceOrientationPortrait, UIInterfacOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight 17、ASIHTTPRequest实现断点下载 - (IBAction)URLFetchWithProgress:(id)sender { [startButton setTitle:@"Stop" forState:UIControlStateNormal]; [startButton addTarget:self action:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; NSString*tempFile = [[[[NSBundle mainBundle] bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip.download"]; if ([[NSFileManager defaultManager] fileExistsAtPath:tempFile]) { [[NSFileManager defaultManager] removeItemAtPath:tempFile error:nil]; } [self resumeURLFetchWithProgress:self]; } - (IBAction)stopURLFetchWithProgress:(id)sender { networkQueue = [[ASINetworkQueue alloc] init]; timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:selfselector:@selector(updateBandwidthUsageIndicator) userInfo:nil repeats:YES]; timer = nil; [startButton setTitle:@"Stop" forState:UIControlStateNormal]; [startButton addTarget:self action:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; [networkQueue cancelAllOperations]; [resumeButton setEnabled:YES]; } - (IBAction)resumeURLFetchWithProgress:(id)sender { [resumeButton setEnabled:NO]; [startButton setTitle:@"Start" forState:UIControlStateNormal]; [startButton addTarget:self action:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; [networkQueue cancelAllOperations]; [networkQueue setShowAccurateProgress:YES]; [networkQueue setDownloadProgressDelegate:progressIndicator]; [networkQueue setDelegate:self]; [networkQueue setRequestDidFinishSelector:@selector(URLFetchWithProgressComplete:)]; ASIHTTPRequest*request=[[[ASIHTTPRequest alloc] initWithURL:[NSURLURLWithString:@"http://9991.net/blog/mp3/2.mp3"]] autorelease]; [request setDownloadDestinationPath:[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MemexTrails_1.0b1.mp3"]]; [request setTemporaryFileDownloadPath:[[[[NSBundle mainBundle] bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip.down"]]; [request setAllowResumeForFileDownloads:YES]; [networkQueue addOperation:request]; [networkQueue go]; } - (void)URLFetchWithProgressComplete:(ASIHTTPRequest *)request { if ([request error]) { fileLocation.text=[NSString stringWithFormat:@"An error occurred:%@",[[[requesterror] userInfo] objectForKey:@"Title"]]; } else { fileLocation.text=[NSString stringWithFormat:@"File downloaded to %@",[requestdownloadDestinationPath]]; } [startButton setTitle:@"Start" forState:UIControlStateNormal]; [startButton addTarget:self action:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside]; } - (IBAction)throttleBandwidth:(id)sender { if ([(UIButton *)sender state] ==YES) { [ASIHTTPRequest setMaxBandwidthPerSecond:ASIWWANBandwidthThrottleAmount]; } else { [ASIHTTPRequest setMaxBandwidthPerSecond:]; } } 18、Safari 启动本地app 在plist文件中加入URL types 结构如下图,在Safari中地址栏输入 设置的字符串,比如设置的是 QQ,地址栏输入 QQ:// 就可以起点本地应用。 19、拖到视频进度与滑动手势冲突解决办法 #pragma mark -#pragma mark UIGestureRecognizerDelegate - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ UIView *touchView = touch.view; if ([touchView isKindOfClass:[UISlider class]]) { return NO; } else { return YES; }} 20、创建并保存Cookie的方法 NSString *cookieString = [NSString stringWithString:[headers objectForKey:@"Cookie"]]; NSMutableDictionary *cookieProperties = [[NSMutableDictionary alloc] init]; [cookieProperties setValue:cookieString forKey:NSHTTPCookieValue]; [cookieProperties setValue:@"QQCookie" forKey:NSHTTPCookieName]; [cookieProperties setValue:@".QQ.com" forKey:NSHTTPCookieDomain]; [cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60] forKey:NSHTTPCookieExpires]; [cookieProperties setValue:@"/" forKey:NSHTTPCookiePath]; NSHTTPCookie *newcookie = [[NSHTTPCookie alloc] initWithProperties:cookieProperties]; [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newcookie]; 21、popover横竖屏位置改变解决办法 1、 delegate中 处理 - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{ userImageShow = NO; if ([popoverController isEqual:myPopover]) { [myPopover release]; myPopover = nil; }} 2、屏幕旋转时重新弹出Popover if (myPopover) { if ((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)) { [myPopover presentPopoverFromRect:CGRectMake(10,180, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; } else { [myPopover presentPopoverFromRect:CGRectMake(20,180, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; } } 22、plist各种key值含义 原文:http://www.minroad.com/?p=434 UIRequiresPersistentWiFi 在程序中弹出wifi选择的key(系统设置中需要将wifi提示打开)UIAppFonts 内嵌字体(http://www.minroad.com/?p=412 有详细介绍)UIApplicationExitsOnSuspend 程序是否在后台运行,自己在进入后台的时候exit(0)是很傻的办法UIBackgroundModes 后台运行时的服务,具体看iOS4的后台介绍UIDeviceFamily array类型(1为iPhone和iPod touch设备,2为iPad)UIFileSharingEnabled 开启itunes共享document文件夹UILaunchImageFile 相当于Default.png(更名而已)UIPrerenderedIcon icon上是否有高光UIRequiredDeviceCapabilities 设备需要的功能(具体点击这里查看)UIStatusBarHidden 状态栏隐藏(和程序内的区别是在于显示Default.png已经生效)UIStatusBarStyle 状态栏类型UIViewEdgeAntialiasing 是否开启抗锯齿CFBundleDisplayName app显示名CFBundleIconFile、CFBundleIconFiles 图标CFBundleName 与CFBundleDisplayName的区别在于这个是短名,16字符之内CFBundleVersion 版本CFBundleURLTypes 自定义url,用于利用url弹回程序CFBundleLocalizations 本地资源的本地化语言,用于itunes页面左下角显示本地话语种CFBundleDevelopmentRegion 也是本地化相关,如果用户所在地没有相应的语言资源,则用这个key的value来作为默认最后附上官方文档,所有的key都有,看英文原版才是正路:)点我进入