working
This commit is contained in:
parent
4050a56295
commit
55734f1579
|
|
@ -51,6 +51,11 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity
|
|||
tableView.deselectRowAtIndexPath(indexPathForSelectedRow, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
||||
|
|
@ -160,9 +165,10 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity
|
|||
mediaType: nohanaImagePickerController.mediaType,
|
||||
shouldShowEmptyAlbum: nohanaImagePickerController.shouldShowEmptyAlbum,
|
||||
handler: { () -> Void in
|
||||
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
||||
momentViewController.isLoading = false
|
||||
momentViewController.collectionView?.reloadData()
|
||||
dispatch_async(dispatch_get_main_queue(), { [weak momentViewController] in
|
||||
momentViewController?.isLoading = false
|
||||
momentViewController?.collectionView?.reloadData()
|
||||
momentViewController?.scrollCollectionViewToInitialPosition()
|
||||
})
|
||||
})
|
||||
case .Albums:
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@ class AssetDetailListViewController: AssetListViewController {
|
|||
forState: [.Normal, .Selected])
|
||||
}
|
||||
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
override func updateTitle() {
|
||||
self.title = ""
|
||||
}
|
||||
|
|
@ -51,16 +47,20 @@ class AssetDetailListViewController: AssetListViewController {
|
|||
nohanaImagePickerController.delegate?.nohanaImagePicker?(nohanaImagePickerController, assetDetailListViewController: self, didChangeAssetDetailPage: indexPath, photoKitAsset: asset.originalAsset)
|
||||
}
|
||||
|
||||
override func scrollCollectionView(to indexPath: NSIndexPath) {
|
||||
guard photoKitAssetList.count > 0 else {
|
||||
return
|
||||
}
|
||||
collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: UICollectionViewScrollPosition.CenteredHorizontally, animated: false)
|
||||
}
|
||||
|
||||
override func scrollCollectionViewToInitialPosition() {
|
||||
guard isFirstAppearance else {
|
||||
return
|
||||
}
|
||||
isFirstAppearance = false
|
||||
guard photoKitAssetList.count > 0 else {
|
||||
return
|
||||
}
|
||||
let indexPath = NSIndexPath(forRow: currentIndexPath.item, inSection: 0)
|
||||
collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: UICollectionViewScrollPosition.CenteredHorizontally, animated: false)
|
||||
scrollCollectionView(to: indexPath)
|
||||
isFirstAppearance = false
|
||||
}
|
||||
|
||||
// MARK: - IBAction
|
||||
|
|
|
|||
|
|
@ -45,22 +45,28 @@ class AssetListViewController: UICollectionViewController {
|
|||
scrollCollectionViewToInitialPosition()
|
||||
}
|
||||
|
||||
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
|
||||
collectionView?.reloadData()
|
||||
scrollCollectionViewToInitialPosition()
|
||||
}
|
||||
|
||||
var isFirstAppearance = true
|
||||
|
||||
func updateTitle() {
|
||||
title = photoKitAssetList.title
|
||||
}
|
||||
|
||||
func scrollCollectionView(to indexPath: NSIndexPath) {
|
||||
collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: .Bottom, animated: false)
|
||||
}
|
||||
|
||||
func scrollCollectionViewToInitialPosition() {
|
||||
guard isFirstAppearance else {
|
||||
return
|
||||
}
|
||||
guard photoKitAssetList.count > 0 else {
|
||||
return
|
||||
}
|
||||
let index = NSIndexPath(forRow: self.photoKitAssetList.count - 1, inSection: 0)
|
||||
collectionView?.scrollToItemAtIndexPath(index, atScrollPosition: .Bottom, animated: false)
|
||||
|
||||
let indexPath = NSIndexPath(forRow: self.photoKitAssetList.count - 1, inSection: 0)
|
||||
scrollCollectionView(to: indexPath)
|
||||
isFirstAppearance = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,18 +26,14 @@ class MomentViewController: AssetListViewController, ActivityIndicatable {
|
|||
guard isFirstAppearance else {
|
||||
return
|
||||
}
|
||||
guard let collectionView = collectionView else {
|
||||
return
|
||||
}
|
||||
let lastSection = momentAlbumList.count - 1
|
||||
guard lastSection >= 0 else {
|
||||
return
|
||||
}
|
||||
|
||||
let index = NSIndexPath(forItem: momentAlbumList[lastSection].count - 1, inSection: lastSection)
|
||||
collectionView.scrollToItemAtIndexPath(index, atScrollPosition: .Bottom, animated: false)
|
||||
let indexPath = NSIndexPath(forItem: momentAlbumList[lastSection].count - 1, inSection: lastSection)
|
||||
scrollCollectionView(to: indexPath)
|
||||
isFirstAppearance = false
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDataSource
|
||||
|
|
|
|||
|
|
@ -100,10 +100,10 @@ public class NohanaImagePickerController: UIViewController {
|
|||
assetCollectionSubtypes: assetCollectionSubtypes,
|
||||
mediaType: mediaType,
|
||||
shouldShowEmptyAlbum: shouldShowEmptyAlbum,
|
||||
handler: {
|
||||
handler: { [weak albumListViewController] in
|
||||
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
||||
albumListViewController.isLoading = false
|
||||
albumListViewController.tableView.reloadData()
|
||||
albumListViewController?.isLoading = false
|
||||
albumListViewController?.tableView.reloadData()
|
||||
})
|
||||
})
|
||||
albumListViewController.nohanaImagePickerController = self
|
||||
|
|
|
|||
|
|
@ -8,7 +8,14 @@
|
|||
|
||||
struct Size {
|
||||
|
||||
static let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height
|
||||
static var statusBarHeight: CGFloat {
|
||||
get {
|
||||
if UIApplication.sharedApplication().statusBarHidden {
|
||||
return 0
|
||||
}
|
||||
return UIApplication.sharedApplication().statusBarFrame.size.height
|
||||
}
|
||||
}
|
||||
|
||||
static func navigationBarHeight(viewController: UIViewController) -> CGFloat {
|
||||
return viewController.navigationController?.navigationBar.frame.size.height ?? CGFloat(44)
|
||||
|
|
|
|||
Loading…
Reference in New Issue