我正在使用Fusuma https://github.com/ytakzk/Fusuma并且在Fusuma中可以使用代码进行微小修改,因此在选择照片或拍摄之后它会将我带到新的视图控制器,例如uploadViewcontroller,其中选择的图像呈现(稍后它会在拍照确认或重拍后再做另一种观点是好的吗?
答案 0 :(得分:0)
只需在image selection delegate
如果您支持allowMultipleSelection = true
然后在那里写导航代码
func fusumaMultipleImageSelected(_ images: [UIImage], source: FusumaMode) {
print("Number of selection images: \(images.count)")
// your navigation code
let viewController = UIViewController()
self.present(viewController, animated: true, completion: nil)
}
如果您支持一个选择allowMultipleSelection = false
在那里写下导航代码
func fusumaImageSelected(_ image: UIImage, source: FusumaMode) {
switch source {
case .camera:
print("Image captured from Camera")
case .library:
print("Image selected from Camera Roll")
default:
print("Image selected")
}
// set you controller there
let viewController = UIViewController()
self.present(viewController, animated: true, completion: nil)
// imageView.image = image
}
答案 1 :(得分:0)
是的,您可以实施FusumaDelegate
方法fusumaImageSelected
(或fusumaMultipleImageSelected
,在那里写任何导航代码(例如segues,navigationController" pushViewController方法或viewControllers& #39;现在)并通过它传递您的图像。
import UIKit
import Fusuma
class ViewController: UIViewController {
@IBOutlet weak var photoLibraryButton: UIButton!
let fusuma = FusumaViewController()
override func viewDidLoad() {
super.viewDidLoad()
fusuma.delegate = self
fusuma.allowMultipleSelection = true
}
@IBAction
func showPhotoLibrary() {
self.present(fusuma, animated: true, completion: nil)
}
}
extension ViewController: FusumaDelegate {
func fusumaImageSelected(_ image: UIImage, source: FusumaMode) {
let vc = UploadViewController()
vc.image = image
self.navigationController?.pushViewController(vc, animated: true)
}
func fusumaMultipleImageSelected(_ images: [UIImage], source: FusumaMode) {
let vc = UploadViewController()
guard let firstImage = images.first else { return }
vc.image = firstImage
self.navigationController?.pushViewController(vc, animated: true)
}
func fusumaVideoCompleted(withFileURL fileURL: URL) {
}
func fusumaCameraRollUnauthorized() {
}
}
然后在UploadViewController中你可以做任何你想做的事情:
import UIKit
class UploadViewController: ViewController {
public var image = UIImage()
var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
imageView = UIImageView(frame: view.frame)
imageView.image = self.image
view.addSubview(imageView)
}
}