我一直在尝试在一个快速的应用程序中使用https://github.com/promet/PRAugmentedReality库.
但当我把它连接到快速项目时,它开始像这样:
下面你可以看到我将这个库集成到我的swift项目中的步骤,我的swift项目的代码以及objective-c和swift项目的下载链接.这里也是PR增强现实框架的YouTube视频:
链接1:Getting Started -> https://www.youtube.com/watch?v=fdN0XAoZXOY
链接2:Walkthrough of Internals-> https://www.youtube.com/watch?v=Xmx-0OnzTPY
Swift项目步骤:
>使用名为demoAR的Xcode Version 7.2.1(7C1002)创建单个视图应用程序
>我从目标添加了Foundation.framework,CoreGraphics.framework和UIKit.framework – > demoAR – >构建阶段 – >链接二进制文件与库
>然后,文件 – >新目标 – > Cocoa Touch Framework并单击Next
>创建了一个具有以下属性的Target:产品名称:PRAR,语言:Objective-C和组织标识符:com.timur.PRAR然后我单击Finish
>我在PRAR下创建了另一个组并将其命名为“Classes”,然后我从框架的Classes文件夹中复制文件并将它们添加到PRAR / Classes文件夹中.
>我将框架目标成员的每个.h文件更改为“公共”
#import <PRAR/ARSettings.h> #import <PRAR/PRARManager.h> #import <PRAR/ARController.h> #import <PRAR/ARObject.h> #import <PRAR/ARRadar.h> #import <PRAR/LocationMath.h>
>为了在我的swift项目中运行此框架所做的其余工作仍在我的ViewController.swift文件中,例如:
import UIKit import PRAR var prARManager = PRARManager() let x: Int32 = AR_VIEW_TAG let y = Int(x) class ViewController: UIViewController,PRARManagerDelegate{ func alert(title: String,withDetails details: String) { print("alert function") let alert: UIAlertView = UIAlertView(title: title,message: details,delegate: nil,cancelButtonTitle: "Ok",otherButtonTitles: "") alert.show() } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,typically from a nib. print("1") // AŞAĞIDAKİ SATIRDA BİR SORUN VAR!!! prARManager = PRARManager.init(size: self.view.frame.size,delegate: self,showRadar: true) print("2") } override func viewDidAppear(animated: Bool) { print("3") let locationCoordinates = CLLocationCoordinate2D(latitude: 41.085468,longitude: 29.044033) print("4") prARManager.startARWithData(self.getDummyData() as [AnyObject],forLocation: locationCoordinates) print("5") } func getDummyData() -> NSArray { print("6") let dummyData: [AnyObject] = [["id": 0,"lat": 40.9780919,"lon": 27.511674,"title": "Tekirdağ"],["id": 1,"lat": 40.8025157,"lon": 29.4397941,"title": "Gebze"]] print("7") return dummyData; } func prarDidSetupAR(arView: UIView,withCameraLayer cameraLayer: AVCaptureVideoPreviewLayer,andRadarView radar: UIView) { print("8") NSLog("Finished displaying ARObjects") print("9") self.view.layer.addSublayer(cameraLayer) print("10") self.view!.addSubview(arView) print("11") self.view.bringSubviewToFront(self.view.viewWithTag(y)!) //self.view.bringSubviewToFront(self.view!.viewWithTag(AR_VIEW_TAG)); //self.view!.bringSubviewToFront(self.view!.viewWithTag( 042313 )!) //print("12") self.view.addSubview(radar) //print("13") } func prarUpdateFrame(arViewFrame: CGRect) { print("14") self.view.viewWithTag(y)?.frame = arViewFrame print("hello") //self.view.viewWithTag(AR_VIEW_TAG)!.frame = arViewFrame //self.view!.viewWithTag(042313)!.frame = arViewFrame print("15") } func prarGotProblem(problemTitle: String!,withDetails problemDetails: String!) { print("16") self.alert(problemTitle,withDetails: problemDetails) print("17") } }
您可以在下面下载objective-c和swift项目.我只是想让swift项目能够作为objective-c项目运行.我怎样才能做到这一点?我经常浏览所有框架和代码,但我看不出有什么问题. * ps:我正在使用Xcode版本7.2.1
Swift项目的链接:https://drive.google.com/file/d/0B-cDfWHidgvcYnFNcnlMZG1aaDg/view?usp=sharing
Objective-C项目的链接:https://drive.google.com/file/d/0B-cDfWHidgvcQUFXbktYSE5CeHM/view?usp=sharing