草庐IT

appDeleg

全部标签

objective-c - 我如何从 objective-c 代码中获取 Swift AppDelegate 的引用

我的项目使用的是Swift3.0,我使用的是xCode8.2。我需要在我的swift项目中导入Objective-C代码。Objective-C需要应用程序委托(delegate)引用。如何从我的Objective-C代码中获取swiftappdelegate引用?在我的Objective-C文件中,#import"AppDelegate.h"给出了未找到的错误,因为它是快速的AppDelegate 最佳答案 正如Kie所说,您需要#import"-Swift.h"在你的Obj-C.m文件以获取所有Swift类。这是一个包含您需要的

ios - 如何在 AppDelegate 中包含 NSPersistentContainer

我收到一个错误:AppDelegatehasnomemberpersistentContainerimportUIKitimportCoreDataclassViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()letappDelegate=UIApplication.sharedApplication().delegateas!AppDelegateletcontext=appDelegate.persistentContainer.viewContext//Error:valueof

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

我导入CoreLocation,然后在didFinishLaunchingWithOptions中添加locationManager.delegate=self和letlocationManager=CLLocationManager()脱离它。但是我在AppDelegate中有这个错误。我做错了什么? 最佳答案 您需要使您的AppDelegate符合CLLocationManagerDelegate。classAppDelegate:UIApplicationDelegate,CLLocationManagerDelegate{}

swift - AppDelegate.swift如何替换Xcode 6.3中的AppDelegate.h和AppDelegate.m

根据iOSDeveloperLibraryTheappdelegateiswhereyouwriteyourcustomapp-levelcode.Likeallclasses,theAppDelegateclassisdefinedintwosourcecodefilesinyourapp:intheinterfacefile,AppDelegate.h,andintheimplementationfile,AppDelegate.m.但是,在Xcode6.3中似乎只有AppDelegate.swift而不再有.h和.m扩展名。我想了解.swift如何替换.h和.m扩展名。

ios - 在 Appdelegate 中设置 RootViewController

我的应用程序中有Storyboard,但我不想在info.plist中设置Mainstoryboardfilebasename,以及我不想为任何ViewController场景设置入口点,即IsInitialViewControllerinstoryboard。虽然我想用Storyboard中的一些场景启动应用程序,但所有显示给我的都是黑屏。当我尝试过lettestob:testClass=testClass()self.window?.rootViewController=testob在AppDelegate中,它没有工作并且出现了同样的黑屏。但是当我在info.plist中设置Ma

ios - 使用 Swift 从 AppDelegate 更改 UINavigationBar 后退按钮文本和字体

我需要更改AppDelegate中的UINavigationBar后退栏按钮文本,以将更改应用到我应用中的所有Views。我已经使用以下方式更改了标题字体样式:UINavigationBar.appearance().titleTextAttributes=[NSFontAttributeName:UIFont(name:"MyCustomFont",size:20)!]但我不知道如何访问左侧栏按钮以对其进行更改。 最佳答案 swift3.0,4.0只需使用UINavigationItem的extension即可实现。根据许多搜索,

ios - 如何获取当前显示的 UIViewController 不在 AppDelegate 中?

我正在尝试获取不在AppDelegate中的当前显示UIViewController,但它似乎总是获取初始顶部UIViewController,而不是当前显示的UIViewController.AppDelegate中的以下代码确实获得了当前的UIViewController,但是当我在我的任何一个ViewController中使用它时,这个相同的功能不起作用:funcgetTopViewController()->UIViewController{vartopViewController=UIApplication.sharedApplication().delegate!.wind

xcode - 从 AppDelegate (Swift) 连接到 ViewController

我使用标准的XcodeSwift模板(使用Storyboard)创建了一个新的OSXCocoa应用程序。我在AppDelegate.swift中实现了一个IBAction来处理用户从"file"菜单中选择“打开...”的情况。如果所选文件是有效的图像文件,我将创建一个NSImage,然后我想将其显示在ViewController的View中。@IBActionfuncopenFile(sender:NSMenuItem){varopenPanel=NSOpenPanel()openPanel.beginWithCompletionHandler{(result:Int)->Voidin

ios - Swift:XCode6 Beta 5 在 AppDelegate 中给出核心数据对象的错误

我正在使用swift编程语言开发应用程序。我使用的是XCode6Beta4版本,所有的东西都运行得很顺利。我今天已将版本更新到Beta5,但我在核心数据对象上收到以下错误:类型“NSManagedObjectContext”不符合协议(protocol)“BooleanType”。类型“NSManagedObjectModel”不符合协议(protocol)“BooleanType”。类型“NSPersistentStoreCoordinator”不符合协议(protocol)“BooleanType”。还附上了错误的屏幕截图。 最佳答案

ios - React Native 0.40.0 : RCTBundleURLProvider. h” 找不到文件 - AppDelegate.m

我遇到以下错误,ReactNative版本0.40.0版本React/RCTBundleURLProvider.h'找不到文件。我尝试删除节点模块,使用npminstall安装它并清除watchman.multiple次。但仍然无法让它工作。 最佳答案 通过在XCode上删除默认目标并重新创建它来让它工作。此外,请务必选中ManageSchemes>[selectyourmaintarget]>Edit>Build选项卡。检查React在列表中,并将方案标记为Shared。否则,它将保存在您用户的文件夹中,GIT将忽略它。希望对你有