确定3G vs边缘

我知道可达性示例允许检测networking是否可以通过Wifi或Cell访问,但有没有方法可以确定单元连接是通过3G还是EDGE?

iOS中的xmlparsing教程

嗨,我创build一个应用程序,必须打印从server.xml中的xml文件标签的值。我试着读谷歌search下的一些文档..但我找不到它…是否有人知道简单的教程或任何用于在我的应用程序中集成xmlparsing的示例代码。

我怎样才能设置CG_CONTEXT_SHOW_BACKTRACE环境variables?

在我看来,我有三个button。 在viewDidLoad()中设置了cornerRadus后: button.layer.cornerRadius = 20我在日志中得到以下错误信息: <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 问题: 我怎样才能设置CG_CONTEXT_SHOW_BACKTRACE环境variables? 或者我该如何解决这个警告? 好吧,我现在从消息中回溯。 这对我没有任何意义。 一些帮助,请… Aug 7 14:27:00 <Error>: CGContextSaveGState: invalid context 0x0. Backtrace: <-[UIStatusBarItemView updateContentsAndWidth]+33> <-[UIStatusBarItemView initWithItem:data:actions:style:]+477> <+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:]+134> <-[UIStatusBarLayoutManager _createViewForItem:withData:actions:]+163> <-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:]+36 <-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:]+92> <-[UIStatusBarForegroundView _setStatusBarData:actions:animated:]+797> <-[UIStatusBarForegroundView setStatusBarData:actions:animated:]+332> <__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke+360> […]

目标C:使用进度条下载文件

我正试图把下载过程中进行同步的进度条。 我的应用程序现在可以使用此代码下载文件… pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://webaddress.com/pro/download/file.pdf"]]; NSString *resourcePDFPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]]; pdfFilePath = [resourcePDFPath stringByAppendingPathComponent:@"myPDF.pdf"]; [pdfData writeToFile:pdfFilePath atomically:YES]; 在此代码的过程中,应用程序在下载过程中停止,这是正常的吗? 现在我想要的是在下载的时候在停止时间放置一个进度条。 我试着查看我在网上find的代码,但是我有点困惑,我想我需要一个一步一步解释的参考。

从WKWebView获取所有的cookies

虽然通过使用NSHTTPCookieStorage.sharedHTTPCookieStorage()从UIWebView获取cookie似乎很简单,但似乎WKWebView将cookie存储在别的地方。 我做了一些研究,并从NSHTTPURLResponse对象中获取了一些cookie。 但是,这并不包含WKWebView使用的所有Cookie: func webView(webView: WKWebView, decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, decisionHandler: (WKNavigationResponsePolicy) -> Void) { if let httpResponse = navigationResponse.response as? NSHTTPURLResponse { if let headers = httpResponse.allHeaderFields as? [String: String], url = httpResponse.URL { let cookies = NSHTTPCookie.cookiesWithResponseHeaderFields(headers, forURL: url) for cookie in cookies { logDebug(cookie.description) logDebug("found cookie " + cookie.name + " " + […]

确定是否拖动/移动MKMapView

有没有一种方法来确定是否一个MKMapView被拖动? 每当用户使用CLLocationCoordinate2D centre = [locationMap centerCoordinate];拖动地图时,我想获取中心位置CLLocationCoordinate2D centre = [locationMap centerCoordinate]; 但是我需要一个委托方法或者一旦用户在地图上浏览时触发的东西。 提前致谢

如何在iOS中释放CGImageRef

我正在写这个方法来计算图像的平均R,G,B值。 以下方法将UIImage作为input,并返回包含input图像的R,G,B值的数组。 我有一个问题:如何/我在哪里正确地释放CGImageRef? -(NSArray *)getAverageRGBValuesFromImage:(UIImage *)image { CGImageRef rawImageRef = [image CGImage]; //This function returns the raw pixel values const UInt8 *rawPixelData = CFDataGetBytePtr(CGDataProviderCopyData(CGImageGetDataProvider(rawImageRef))); NSUInteger imageHeight = CGImageGetHeight(rawImageRef); NSUInteger imageWidth = CGImageGetWidth(rawImageRef); //Here I sort the R,G,B, values and get the average over the whole image int i = 0; unsigned int red = 0; […]

如何让我的AVPlayer在应用程序在后台播放?

我已经完成了我的功课…一直在这里阅读,文档,谷歌search,stackoverflowing …但仍然没有运气让我的声音棒,当用户使应用程序进入后台。 到目前为止我所做的:将UIBackgroundModes,audio添加到plist文件。 首先这个代码: radioAudio = [[AVAudioSession alloc] init]; [radioAudio setCategory:AVAudioSessionCategoryPlayback error:nil]; [radioAudio setActive:YES error:nil]; 那么这个: NSString *radioURL = @"http://xxx.xxx.xxx/radio.m3u"; radioPlayer = [[AVPlayer playerWithURL:[NSURL URLWithString:radioURL]] retain]; 但只要用户点击主页button,我的声音就会消失。 我也发现这个,但没有添加cuase一些我读过的东西说这是不需要的; newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL]; if (newTaskId != UIBackgroundTaskInvalid && bgTaskId != UIBackgroundTaskInvalid) [[UIApplication sharedApplication] endBackgroundTask: bgTaskId]; bgTaskId = newTaskId; 现在我不知道该怎么去让我的AVPlayer让广播歌曲,而用户在电话上做其他的东西。 我正在用4.2testingiPhone 4。 build设4.0。 任何人有什么build议我应该做的?

如何设置UIImage的不透明度/ alpha值?

我知道你可以用UIImageView做到这一点,但可以做到UIImage? 我想要一个UIImageView的animation图像数组属性是一个相同的图像,但不同的不透明度的数组。 思考?

使用UIWebView从HTML代码调用目标c代码中的方法

我的iOS应用程序中有.html文件。 HTML文件几乎没有使用onClick方法的div块。 当我点击这些块时,我会在Web视图中调用一些JavaScript代码,但是我也需要在源代码中了解这些事件。 例如,当我点击web元素和onClick被调用时,我需要在代码中调用一些方法,例如- (void)didTouchedWebElementWithId 我可以做这个东西吗? 谢谢。