Tag: ios

ios UTF8编码从nsstring

我正在收到一个没有正确编码的nsstring,比如“mystring%201,其中必须是”mystring 1“,我怎样才能replace所有可以被解释为UTF8的字符?我读了很多post,但没有一个完整的解决scheme。注意,nsstring已经被编码错了,我不问如何编码字符序列,谢谢。

如何在MPMoviePlayerController播放失败时获取错误描述

如果video播放失败,我想显示一个UIAlert 。 所以我注册了我的电影播放器​​的MPMoviePlayerPlaybackDidFinishNotification : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback 🙂 name:MPMoviePlayerPlaybackDidFinishNotification object:self.movi​​ePlayer]; 在我的myMovieFinishedCallback中:我检查用户信息词典中是否有一个名为error的对象。 在我的真实设备上,我没有得到这个错误(没有networking错误,文件的404错误)。 在iPhone模拟器上,我收到错误。 当我收到MPMoviePlayerPlaybackDidFinishNotification时,如何正确地检查推理?

“该应用程序没有有效的签名”XCode 4.3

我今天得到最奇怪的错误。 “申请没有有效的签名” 当我尝试从设备上的XCode 4.3运行应用程序时出现此错误。 另外,当我存档它显示为一个通用的档案,而不是一个真正的应用程序。 当然,我删除了所有无效的configuration文件,清理了我的派生数据,清理了我的目标,然后重新启动。 没有运气。 编辑:原来,我有我的应用程序中的文件夹引用。 我删除了所有对这些文件夹的引用,并将它们设置为组,并且工作正常!

在Uiwebview中显示video不在设备全屏幕中

我想在UIWebview中显示video。 当我们点击video时,它会在设备上全屏播放。 我们如何在UIWebview中播放video? 请注意,这些video文件托pipe在YouTube或我们的服务器上。 他们不与应用程序捆绑在一起

停止使用RepeatsForever – Sprite Kit的SKAction

我想根据它的旋转在我的精灵节点上运行两个animation。 如果值是负值,则运行其中一个animation,如果是正值,则运行另一个animation。 而我设法做到这一点(但)我有一个问题。 如果Animation1正在运行,并且zRotation更改为正值,则它们都会运行,因为它们会一直重复。 所以我这样做了: NSMutableArray *walkingTextures = [NSMutableArray arrayWithCapacity:14]; for (int i = 1; i < 15; i++) { NSString *textureName = [NSString stringWithFormat:@"character%d", i]; SKTexture *texture = [SKTexture textureWithImageNamed:textureName]; [walkingTextures addObject:texture]; } SKAction *spriteAnimation = [SKAction animateWithTextures:Textures timePerFrame:0.04]; repeatWalkAnimation = [SKAction repeatActionForever:spriteAnimation]; [sprite runAction:repeatWalkAnimation withKey:@"animation1"]; 然后当我想要它停止时: [self removeActionForKey:@"animation1"]; 但它一直在运行,我怎么能停止这个动作呢? 谢谢!

使用新的Swift 3和AlamofireparsingJSON

我使用Alamofire作为HTTP库,因为Swift 3的更新,如何根据下面的例子来parsingJSON? Alamofire.request("https://httpbin.org/get").responseJSON { response in debugPrint(response) if let json = response.result.value { print("JSON: \(json)") } } respone.result.value是任何对象,是非常新的和混乱的。

在iOS7上区分屏幕locking和主页button

我需要在applicationDidEnterBackground做一些事情。 但我需要区分哪些用户行为导致“进入背景”:屏幕locking或主页按下button。 我正在使用这个代码,这是从这篇文章 – 如何区分iOS5上的屏幕locking和主页button? : UIApplicationState state = [application applicationState]; if (state == UIApplicationStateInactive) { NSLog(@"Sent to background by locking screen"); } else if (state == UIApplicationStateBackground) { NSLog(@"Sent to background by home button/switching to other app"); } 它在iOS6上正常工作。 但在iOS7(设备和模拟器),我总是得到UIApplicationStateBackground ,无论用户点击主页还是lockingbutton。 有人有什么可能导致这个问题的想法吗? iOS 7更新到多任务后台处理? 或者我的应用程序的一些设置(我的应用程序的背景模式closures)? 还有其他解决scheme吗?

我们如何在整个应用程序中设置iOS 9状态栏的Light内容风格?

我想将Light Content样式应用于整个应用程序。 以下方法在iOS 9中不推荐使用replace方法。 -setStatusBarStyle:animation: 设置状态栏的样式,可select将animation过渡到新样式。 在AppDelegate工作就像: Swift 1.2代码: UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true) 但是当我将我的项目升级到iOS 9 / Swift 2时,他们给我的警告信息是: <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. <Error>: CGContextRestoreGState: invalid context […]

在iOS7上检测应用程序何时从locking屏幕变为活动状态

从locking屏幕变为活动状态时(locking状态),我的应用程序具有不同的行为,或者从其他任何情况变为活动状态。 在iOS 6和更低,我可以检测到这一点 UIApplicationState state = [[UIApplication sharedApplication] applicationState]; if (UIApplicationStateInactive == state) // Coming from locked screen (iOS 6) else // Coming from Springboard, another app, etc… 但在iOS 7上,两种情况下的状态值均为UIApplicationStateBackground 。 这是预期的行为? 如何正确检测应用程序是否从锁屏启动? 注册的开发者,我已经在NDA解除之前在devforums上发布了,请看这里

获取NSString高度

我有一个NSString,我想知道它的高度来创build一个合适的UILabel。 这样做 NSString *string = @"this is an example"; CGSize size = [string sizeWithFont:[UIFont systemFontOfSize:10.0f] forWidth:353.0 lineBreakMode:UILineBreakModeWordWrap]; float height = size.height; 身高现在是13.0。 如果我使用这个string NSString *string = @"this is an example this is an example this is an example this is an example this is an example this is an example this is an example this […]