p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea; min-height: 16.0px }
span.s1 { color: #ba2da2 }
span.s2 { color: #703daa }
span.s3 { color: #3e1e81 }
span.s4 { color: #4f8187 }
span.s5 { color: #d12f1b }
span.s6 { color: #272ad8 }
// 注意判断条件,
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let cell = sender as? UICollectionViewCell,
let indexPath = collectionView?.indexPath(for: cell),
let managePageViewController = segue.destination as? ManagePageViewController {
managePageViewController.photos = photos
managePageViewController.currentIndex = indexPath.row
}
}
}
// UIPageViewController 用法
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #3e1e81; background-color: #fffcea }
span.s1 { color: #ba2da2 }
span.s2 { color: #31595d }
span.s3 { color: #4f8187 }
span.s4 { color: #272ad8 }
span.s5 { color: #000000 }
span.s6 { color: #3e1e81 }
if let viewController = viewPhotoCommentController(index: currentIndex ?? 0) {
let viewControllers = [viewController]
setViewControllers (
viewControllers,
direction: .forward,
animated: false,
completion: nil
)
}
// 来自storyboard的VC,初始化方法
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4f8187; background-color: #fffcea }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea; min-height: 16.0px }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #ba2da2; background-color: #fffcea }
span.s1 { color: #ba2da2 }
span.s2 { color: #703daa }
span.s3 { color: #4f8187 }
span.s4 { color: #3e1e81 }
span.s5 { color: #d12f1b }
span.s6 { color: #000000 }
fileprivate func viewPhotoCommentController(index: Int) -> PhotoCommentViewController? {
if let storyboard = storyboard,
let page = storyboard.instantiateViewController(withIdentifier: "PhotoCommentViewController")
as? PhotoCommentViewController {
page.photoName = photos[index]
page.photoIndex = index
return page
}
return nil
}
// UIPageViewControllerDataSource
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #703daa; background-color: #fffcea }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea; min-height: 16.0px }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #31595d; background-color: #fffcea }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #ba2da2; background-color: #fffcea }
p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #008400; background-color: #fffcea }
p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4f8187; background-color: #fffcea }
span.s1 { color: #ba2da2 }
span.s2 { color: #000000 }
span.s3 { color: #4f8187 }
span.s4 { color: #703daa }
span.s5 { color: #272ad8 }
extension ManagePageViewController: UIPageViewControllerDataSource {
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if let viewController = viewController as? PhotoCommentViewController {
guard let index = viewController.photoIndex, index != 0 else {
return nil
}
return viewPhotoCommentController(index: index - 1)
}
return nil
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if let viewController = viewController as? PhotoCommentViewController {
guard let index = viewController.photoIndex, index != photos.count - 1 else {
return nil
}
return viewPhotoCommentController(index: index + 1)
}
return nil
}
/// MARK: UIPageControl
func presentationCount(for pageViewController: UIPageViewController) -> Int {
return photos.count
}
func presentationIndex(for pageViewController: UIPageViewController) -> Int {
return currentIndex ?? 0
}
}
// 初始化Selector
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #ba2da2; background-color: #fffcea }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4f8187; background-color: #fffcea }
span.s1 { color: #000000 }
span.s2 { color: #703daa }
span.s3 { color: #ba2da2 }
span.s4 { color: #4f8187 }
span.s5 { color: #31595d }
fileprivate extension Selector {
static let keyboardWillShowHandler = #selector(PhotoCommentViewController.keyboardWillShow(notification:))
static let keyboardWillHideHandler = #selector(PhotoCommentViewController.keyboardWillHide(notification:))
static let generalTap = #selector(PhotoCommentViewController.dismissKeyboard)
static let zoomTap = #selector(PhotoCommentViewController.openZoomingController(sender:))
}
// UIScrollViewDelegate
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4f8187; background-color: #fffcea }
span.s1 { color: #ba2da2 }
span.s2 { color: #703daa }
span.s3 { color: #000000 }
span.s4 { color: #31595d }
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return myImageView
}
func scrollViewDidZoom(_ scrollView: UIScrollView) {
updateConstraints(forSize: view.bounds.size)
}
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #703daa; background-color: #fffcea }
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; background-color: #fffcea }
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #703daa; background-color: #fffcea }