     override func viewDidLoad() {
         super.viewDidLoad()
         self.title = String.localizedString(for: "MEDIA")
+        if UIDevice.current.userInterfaceIdiom == .pad {
+            itemsPerRow = 6
+        } else {
+            itemsPerRow = 3
+        }
         automaticallyAdjustsScrollViewInsets = false
         setupActivityIndicator()
         PHPhotoLibrary.requestAuthorization { (status) in

extension MediaViewController: UICollectionViewDelegateFlowLayout {

    public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        let paddingSpace = sectionInsets.left * (itemsPerRow + 1)
        let availableWidth = view.frame.width - paddingSpace
        let widthPerItem = availableWidth / itemsPerRow

        return CGSize(width: widthPerItem, height: widthPerItem)
    }

class MediaViewController: UIViewController {

    @IBOutlet var collectionView: UICollectionView?
    var itemsPerRow: CGFloat?
    let sectionInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
    var dataSource: [PHAsset] = []
    var activityIndicatorView: UIActivityIndicatorView?
