JiongXing / PhotoBrowser

Elegant photo browser in Swift. 图片与视频浏览器。
MIT License
1.31k stars 206 forks source link

请问在长按方法里如何弹出一个保存图片的小框? #14

Closed apiapia closed 7 years ago

apiapia commented 7 years ago

func photoBrowser(_ photoBrowser: PhotoBrowser, didLongPressForIndex index: Int, image: UIImage) { print("长按,图片size:(image.size)") imageViewLongPressGestureRecognizer(image) }

/// 长按图片事件
func imageViewLongPressGestureRecognizer(_ saveImage:UIImage) {
    // 暂时先用 actionSheet 吧
    let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

    let saveImageAction = UIAlertAction(title: "保存图片", style: .default) { (_) in
        print("保存\(saveImage)")
    }
    let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil)

    actionSheet.addAction(saveImageAction)
    actionSheet.addAction(cancelAction)
    present(actionSheet, animated: true, completion: nil)
}

上面这样子提示 下列错误,也无法弹出框 2017-08-30 17:39:46.562 PhotoBrowser[7622:1035904] Warning: Attempt to present <UIAlertController: 0x7fbe2d912cf0> on <PhotoBrowser.MomentsViewController: 0x7fbe2b606020> which is already presenting <JXPhotoBrowser.PhotoBrowser: 0x7fbe2b50e0d0>

JiongXing commented 7 years ago

稍等,我在demo示例一下

JiongXing commented 7 years ago

用photoBrowser来present,我已更新代码。对应cocoapods 0.3.5

hanlike commented 5 years ago

咦。我用photoBrowser 来present一个UIAlertController(actionSheet)的时候 会

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-08-29 11:23:26.375017+0800 Runner[449:49445] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x2833367b0 UIView:0x123e89870.width == - 16   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x2833367b0 UIView:0x123e89870.width == - 16   (active)>
JiongXing commented 5 years ago

@thecorsair Demo里面也有present ActionSheet,你运行那个看看有没问题,看能不能找到原因?