草庐IT

appDeleg

全部标签

ios - 为什么 AppDelegate 继承自 UIResponder?

我注意到在Xcode4.2beta4中使用iPhoneMaster-Detail模板创建新项目时,它会://AppDelegate.h@interfaceAppDelegate:UIResponder为什么AppDelegate继承自UIResponder而不是NSObject? 最佳答案 来自ConvertingtoStoryboardsReleaseNotes:Note:InthecurrentXcodetemplates,theapplicationdelegateclassinheritsfromUIResponder.Th

ios - 在 AppDelegate 中,主 UIWindow 是如何实例化的?

Master-DetailXcode项目中的默认代码片段AppDelegate.m-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{//Overridepointforcustomizationafterapplicationlaunch.UINavigationController*navigationController=(UINavigationController*)self.window.rootViewControl

ios - 导入 AppDelegate

我经常在我的AppDelegate中初始化我的模型类变量,这样它们就可以被不同的ViewControllers使用,而无需跨类文件传递它们的实例。但是,每次我将AppDelegate导入.m文件以访问这些变量的数据时,我都觉得自己做错了什么。这是访问这些变量的正确方法还是我应该做一些不同的事情?编辑:我的问题不是如何访问变量。我目前使用这行代码来获取我的appDelegate实例:idappDelegate=[[UIApplicationsharedApplication]delegate];从概念上讲,我想知道这是否是与应用程序的模型类交互的公认方式。在我看来,应用程序的AppDel

ios - 如何从 Appdelegate 显示 UIAlertController

我正在iOS应用程序上使用PushNotification。我想在应用收到通知时显示一个UIalertcontroller。我在AppDelegate中尝试以下代码:[self.window.rootViewControllerpresentViewController:alertanimated:YEScompletion:nil];但UIAlertcontroller显示在RootView(第一个屏幕)中,对于其他uiviewcontroller,我收到警告或应用程序崩溃。 最佳答案 试试这个objective-CUIWindo

ios - 如何从我的 appDelegate 访问我的 viewController?苹果系统

我有一个在xCode中创建为“基于View的应用程序”的iOS应用程序。我只有一个viewController,但它会自动显示,而且我看不到任何将它与我的appDelegate关联的代码。我需要将数据从我的appDelegate传递到我的viewController,但不知道如何实现。我的应用委托(delegate).h:#import@interfaceAppDelegate:UIResponder@property(strong,nonatomic)UIWindow*window;@property(strong,nonatomic)NSDictionary*queryString

iphone - 在 AppDelegate.m 中获取当前显示在屏幕上的 UIViewController

屏幕上的当前UIViewController需要通过设置一些角标(Badge)View来响应来自APNs的推送通知。但是我怎样才能在AppDelegate.m的方法application:didReceiveRemoteNotification:中获取UIViewController?我尝试使用self.window.rootViewController获取当前显示的UIViewController,它可能是UINavigationViewController或其他类型的ViewController。我发现UINavigationViewController的visibleViewCo

ios - 如何重构我的代码以在主线程上调用 AppDelegate?

我最近开始将我的项目从Swift3/Xcode8迁移到Swift4/Xcode9。我的应用程序在运行时崩溃,因为主线程清理器只允许在主线程上访问UIApplication.shared.delegate,导致启动时崩溃。我有以下代码,它在Swift3中运行良好-staticvarappDelegate:AppDelegate{returnUIApplication.shared.delegateas!AppDelegate;}我代码中的其他类可以访问appDelegate。我需要找出一种从主线程返回UIApplication.shared.delegate的方法。注意:从访问appDe

ios - 无法在 Swift AppDelegate 文件中访问 Google Map Framework

我正在研究Swift,并且正在努力弄清楚如何集成GoogleMapSDK框架。我在Xcode6中创建了一个新项目,按照适用于iOS的GoogleMapSDK说明导入了所需的框架。但是,当我使用(import)将GoogleMaps框架导入AppDelegate.swift文件时,无法识别该框架。到处都找不到解决方案。请帮忙。 最佳答案 导入GoogleMapsiOSSDK后,您需要定义桥接header,SDK才能被识别。要创建此桥接header,请将任意Objective-C文件(例如:.m文件)添加到您的项目中。Xcode会提示你

ios - Firebase - 无法将类型 'AppDelegate' 的值分配给类型 'UNUserNotificationCenterDelegate?'

使用本教程部署firebase时,我总是遇到编译错误:https://firebase.google.com/docs/cloud-messaging/ios/client我的部署SDK是9.0。我得到的错误:我该如何解决这个问题?Cannotassignvalueoftype'AppDelegate'totype'UNUserNotificationCenterDelegate?'第一个场景——我一步一步做了什么(按照教程):pod初始化如下:pod'Firebase/Core'pod'Firebase/消息'pods安装在AppDelegate类之上“导入Firebase”第二种情

ios - 线程 1 : signal SIGABRT AppDelegate. swift

我尝试编译我的第一个iOSHello应用。我有ViewController.swift////ViewController.swift//MyFirstProjectimportUIKitclassViewController:UIViewController{//Declarecomponents@IBOutletweakvarinputLabel:UILabel!overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.}@IBAc