草庐IT

Uiapplication

全部标签

ios - 打开设置 iOS 8 URL

我们如何使用UIApplication.sharedApplication()打开设置我应该传入什么URL?我使用了UIApplicationOpenSettingsURLString但它直接打开到应用程序特定设置页面。但我想让它打开“设置”应用的第一级。或者更好的是,我希望它直接打开到用户可以在手机上启用定位服务的页面。下面的代码直接打开应用程序特定设置页面。UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!); 最佳答案

xcode - AVPlayer 一旦移动到背景就卡住

我有以下加载视频并循环播放的代码。但是,当按下主页并返回到应用程序时,视频会卡住并且不会再次播放。我觉得答案在AppDelegate函数中,但似乎无法让它们工作。importUIKitimportAVKitimportAVFoundationclassViewController:UIViewController,UIApplicationDelegate{varvideoPlayer:AVPlayer!varplayerLayer:AVPlayerLayer?overridefuncviewDidLoad(){super.viewDidLoad()letpath=NSBundle.m

ios - NSInternalInconsistencyException : There can only be one UIApplication instance

描述:尝试使用UIApplication类在我的应用程序中打开YoutubeURL。leturl=URL(string:"https://www.youtube.com/watch?v=smOp5aK-_h0")!letapp=UIApplication()ifapp.canOpenURL(url){//Crashhereapp.openURL(url)}问题:为什么当我尝试打开url时我的应用程序崩溃了?错误:*Assertionfailurein-[UIApplicationinit],*Terminatingappduetouncaughtexception'NSInternal

ios - didRegisterForRemoteNotificationsWithDeviceToken 在 ios 10 上没有被调用

我已经在appDelegate中编写了这段代码importUserNotificationsvarregisterId=String()funcapplication(application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[NSObject:AnyObject]?)->Bool{self.registerForPushNotifications(application)returntrue}funcapplication(application:UIApplication,didRegisterForR

ios - 如何在 iOS 中获取设备 token ?

我正在处理推送通知。我编写了以下代码来获取设备token。-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{[self.windowaddSubview:viewController.view];[self.windowmakeKeyAndVisible];NSLog(@"Registeringforpushnotifications...");[[UIApplicationsharedApplication]registerF

swift - 为什么 "var delegate: UIApplicationDelegate?"在 UIApplication 中成为可选项?那会是 fatal error 吗?

如果delegate属性曾经是nil,应用将处于不可恢复的状态。classUIApplicationDeclarationunowned(unsafe)vardelegate:UIApplicationDelegate?DiscussionEveryappmusthaveanappdelegateobjecttorespondtoapp-relatedmessages.Forexample,theappnotifiesitsdelegatewhentheappfinisheslaunchingandwhenitsforegroundorbackgroundexecutionstatus

swift - 如何在 Swift 中为 performFetchWithCompletionHandler 调用 completionHandler

如何在Swift中为后台提取调用完成处理程序。我执行以下操作:funcapplication(application:UIApplication,performFetchWithCompletionHandlercompletionHandler:(UIBackgroundFetchResult)->Void){//DosomethingcompletionHandler(UIBackgroundFetchResultNoData)//Thisdoesnotwork:(return}你能帮帮我吗?谢谢,托比 最佳答案 枚举大小写是U

swift - 无法在 iOS8 上设置交互式推送通知

我已经能够设置交互式本地通知,但远程通知不起作用。我正在使用Parse.com发送JSON我的AppDelegate.Swift看起来像这样:////AppDelegate.swift//SwifferApp////CreatedbyTrainingon29/06/14.//Copyright(c)2014Training.Allrightsreserved.//importUIKit@UIApplicationMainclassAppDelegate:UIResponder,UIApplicationDelegate{varwindow:UIWindow?funcapplicatio

swift - 从远程通知打开 ViewController

当我的应用捕捉到远程通知时,我尝试打开一个特定的ViewController。让我展示一下我的项目架构。这是我的Storyboard:当我收到通知时,我想打开一个“SimplePostViewController”,所以这是我的appDelegate:varwindow:UIWindow?varnavigationVC:UINavigationController?funcapplication(application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[NSObject:AnyObject]?)->Boo

unit-testing - UIApplication.sharedApplication().delegate 作为 AppDelegate 导致 EXC_BAD_ACCESS 在快速单元测试中使用它

我正在尝试快速使用单元测试来测试一些真实的应用程序行为。当我尝试从我的测试函数将UIApplicationDelegate转换为我的AppDelegate时,我得到了EXC_BAD_ACCESS异常。测试代码下方:functestGetAppDelegate(){letsomeDelegate=UIApplication.sharedApplication().delegateletappDelegate=someDelegateasAppDelegate//EXC_BAD_ACCESShereXCTAssertNotNil(appDelegate,"failedtogetcastpo