我是swift 3和cocoapods的初学者,我想为我的项目实现这个https://github.com/luowenxing/MTImagePicker图片选择器。
我已将pod安装到我的项目中并使用.xcworkspace文件。
但是,我遇到的问题包括:
我已按照指示将MTImagePicker文件夹移动到我的项目中。
但我仍然遇到这个问题。
非常感谢任何帮助。
非常感谢你!
编辑:
Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'BPMatters' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for BPMatters
source 'https://github.com/CocoaPods/Specs.git'
pod 'MTImagePicker', '~> 1.0.1'
target 'BPMattersTests' do
inherit! :search_paths
# Pods for testing
end
target 'BPMattersUITests' do
inherit! :search_paths
# Pods for testing
end
end
@objc protocol MTImagePickerControllerDelegate:NSObjectProtocol {
// Implement it when setting source to MTImagePickerSource.ALAsset
optional func imagePickerController(picker:MTImagePickerController, didFinishPickingWithAssetsModels models:[MTImagePickerAssetsModel])
// Implement it when setting source to MTImagePickerSource.Photos
@available(iOS 8.0, *)
optional func imagePickerController(picker:MTImagePickerController, didFinishPickingWithPhotosModels models:[MTImagePickerPhotosModel])
optional func imagePickerControllerDidCancel(picker: MTImagePickerController)
}
///third party image picker////
func thirdPartyImagePicker(){
let imagePicker = MTImagePickerController.instance
imagePicker.mediaTypes = [MTImagePickerMediaType.Photo,MTImagePickerMediaType.Video]
imagePicker.imagePickerDelegate = self
imagePicker.maxCount = 10 // max select count
imagePicker.defaultShowCameraRoll = true // when set to true would show Camera Roll Album like WeChat by default.
//default is MTImagePickerSource.ALAsset
imagePicker.source = MTImagePickerSource.ALAsset
//imagePicker.source = MTImagePickerSource.Photos (Work on iOS8+)
self.presentViewController(imagePicker, animated: true, completion: nil)
}
///third party image picker end///
Screenshot of Terminal after pod install
解决方案:我通过这样做来完成我的工作:https://stackoverflow.com/a/39435421/7498313
我将Faris Sbahi的答案标记为正确的答案,因为我相信他的答案可以帮助像我这样的初学者设置cocoapods和项目的实施。
非常感谢你! :)
答案 0 :(得分:0)
import MTImagePicker
位于班级的顶端。
将您的Podfile更新为
<强> Podfile 强>
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
use_frameworks!
target 'BPMatters' do
# Pods for BPMatters
pod 'MTImagePicker', '~> 1.0.1'
end
target 'BPMattersTests' do
inherit! :search_paths
# Pods for testing
end
target 'BPMattersUITests' do
inherit! :search_paths
# Pods for testing
end
将Podfile更新为此后,运行pod install
并确保不会返回任何错误。执行此操作后,打开xcworkspace文件,当您尝试构建时,确保目标是BPMatters。
使用MTImagePicker的文件夹