我将Swift 3项目安装了一个Objective C吊舱。我在Podfile中包含“ use_frameworks”,因此不需要在桥接头中添加任何内容。
问题是当我包含一个(第三方)生成的ObjectiveC文件,该文件试图从pod中导入一个标头时-它失败,并显示“'[xxxxx] .h'文件未找到”
ObjectiveC #import“ GTLRObject.h”语句导致“找不到GTLRObject.h文件”错误。
我的Podfile:
target 'myHelloWorld' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'GoogleAPIClientForREST'
end
Run Code Online (Sandbox Code Playgroud)
桥接头。我需要包括生成的ObjectiveC类的标题,以便可以在我的swift代码中使用它:
#import "GTLREcho.h"
Run Code Online (Sandbox Code Playgroud)
GTLREcho.h:
// NOTE: This file was generated by the ServiceGenerator.
// ----------------------------------------------------------------------------
// API:
// echo/v1
// Description:
// This is an API
#import "GTLREchoObjects.h"
#import "GTLREchoQuery.h"
#import "GTLREchoService.h"
Run Code Online (Sandbox Code Playgroud)
GTLREchoObjects.h中出现错误。#import“ GTLRObject.h” = “找不到'GTLRObject.h'文件”:
#if GTLR_BUILT_AS_FRAMEWORK
#import "GTLR/GTLRObject.h"
#else
#import "GTLRObject.h"
#endif
Run Code Online (Sandbox Code Playgroud)
如果我尝试从一个快速文件中引用GTLRObject,我不会得到任何错误,例如 …
我在GMSMapView上调用animateWithCameraUpdate,期望它更改地图视图以显示新的GMSCoordinateBounds,但它没有任何效果.
我的地图加载到UICollectionViewReusableView中以初始显示西欧:
@IBOutlet weak var mapView: GMSMapView!
var fetchedResultsController : NSFetchedResultsController!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
let camera = GMSCameraPosition.cameraWithLatitude(51.48, longitude: 0, zoom: 4)
mapView.camera = camera
}
Run Code Online (Sandbox Code Playgroud)
然后我调用一个函数来查询我的所有位置并更新GMSMapView以显示我的所有位置:
func plotAll(){
let bounds = GMSCoordinateBounds.init()
for property in fetchedResultsController.fetchedObjects!
{
let capitalAsset : CapitalAsset = property as! CapitalAsset
let marker = GMSMarker.init()
marker.draggable = false
marker.snippet = capitalAsset.address
let location = CLLocationCoordinate2DMake(Double(capitalAsset.latitude!), Double(capitalAsset.longitude!))
marker.position = location
marker.map = mapView
// Update bounds to include marker
bounds.includingCoordinate(marker.position)
} …Run Code Online (Sandbox Code Playgroud) 我正在使用带有MapView的应用程序,我有一个自定义按钮,该按钮显示在MapView的顶部。当用户单击该按钮时,我想启动相机,然后用户在该相机上拍照并选择“使用照片”。除了下一部分,我已经完成了所有这些工作。一旦用户选择“使用照片”,我希望将捕获的图像传递给另一个功能。然后释放视图,并返回到地图。.我想使用完成处理程序可以完成此操作吗?但是我不太清楚这是否是最好的方法,如果是的话,如何将UIImage类型的图像传递给要处理的函数。有人可以帮忙吗?
我现在有类似以下内容:
@IBAction func mapButton(sender: AnyObject) {
let image = UIImagePickerController()
//image.delegate = self
image.sourceType = UIImagePickerControllerSourceType.Camera
image.allowsEditing = false
self.presentViewController(image, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
self.dismissViewControllerAnimated(true, completion: customFunction(image))
}
func customFunction(image: UIImage) {
print("Do Something with Image")
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的应用弹出一个弹出窗口。到目前为止,弹出窗口以固定的坐标弹出,我试图将其弹出到用户点击的位置。这就是我所拥有的:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("touchesbegan")
for touch in touches{
//Handle touch
let location = touch.locationInView(self.view)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ColonyPopoverController") as! ColonyPopoverController
vc.modalPresentationStyle = .Popover
vc.preferredContentSize = CGSizeMake(200, 150)
if let popoverController = vc.popoverPresentationController {
popoverController.delegate = self
popoverController.sourceRect = CGRectMake(location.x, location.y, 20, 10)
popoverController.sourceView = self.view
self.presentViewController(vc, animated: true, completion: nil)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我注意到当我点击模拟器时,打印语句永远不会打印。
我认为interaction并已multi-touch启用。我知道这种方法很好用,因为我也将其与Google Maps集成在一起,因此当我点击时,会出现一个google pin:
func mapView(mapView: GMSMapView!, didTapAtCoordinate coordinate: CLLocationCoordinate2D) …Run Code Online (Sandbox Code Playgroud)