Просмотр исходного кода

Segue from album view controller implemented.

Iñigo Valentin 9 лет назад
Родитель
Сommit
ff0103a73d
4 измененных файлов с 25 добавлено и 2 удалено
  1. 18 0
      app/AlbumViewController.swift
  2. 1 0
      app/AppDelegate.swift
  3. 4 0
      app/Base.lproj/Main.storyboard
  4. 2 2
      app/RowAlbum.swift

+ 18 - 0
app/AlbumViewController.swift

@@ -61,6 +61,10 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		
 		// Set button action
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+		
+		// Set this controller in the delegate
+		self.delegate = UIApplication.shared.delegate as? AppDelegate
+		self.delegate?.albumController = self
 	}
 	
 	
@@ -177,5 +181,19 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		}
 	}
 	
+	
+	/**
+	Shows a photo.
+	:param: id The album id.
+	*/
+	func showPhoto(album: Int, photo: Int){
+		NSLog(":ALBUMCONTROLLER:DEBUG: Showing photo \(photo) of album \(album)")
+		// TODO: Set thoese variables and the prepare method
+		//self.passAlbum = album
+		//self.passId = photo
+		performSegue(withIdentifier: "SeguePhotoAlbum", sender: nil)
+		NSLog(":ALBUMCONTROLLER:DEBUG: PHOTO should be shown")
+	}
+	
 }
 

+ 1 - 0
app/AppDelegate.swift

@@ -27,6 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
 	var window: UIWindow?
 	var controller: ViewController?
+	var albumController: AlbumViewController?
 
 	
 	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

+ 4 - 0
app/Base.lproj/Main.storyboard

@@ -697,6 +697,7 @@
                         <outlet property="albumView" destination="YEF-04-q7Y" id="7tR-Lr-9nh"/>
                         <outlet property="barButton" destination="Thj-0t-rxK" id="6bX-xo-abt"/>
                         <outlet property="barTitle" destination="LLe-aQ-Sbj" id="bFR-jT-Xmq"/>
+                        <segue destination="hRA-2q-Tv9" kind="show" identifier="SeguePhotoAlbum" id="ftR-BO-YPe"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="GLj-OZ-Cqc" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -1460,4 +1461,7 @@
         <image name="Logo" width="83" height="83"/>
         <image name="PhotoPlaceholder" width="170" height="108"/>
     </resources>
+    <inferredMetricsTieBreakers>
+        <segue reference="ftR-BO-YPe"/>
+    </inferredMetricsTieBreakers>
 </document>

+ 2 - 2
app/RowAlbum.swift

@@ -101,13 +101,13 @@ Extension of UIView to be formatted as sections.
 	func openLeftPhoto(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":ROWALBUM:DEBUG: Getting delegate and showing left photo.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-		delegate.controller?.showPhoto(album: self.id, photo: self.photoIds[0])
+		delegate.albumController?.showPhoto(album: self.id, photo: self.photoIds[0])
 	}
 	
 	func openRightPhoto(_ sender:UITapGestureRecognizer? = nil){
 		NSLog(":ROWALBUM:DEBUG: Getting delegate and showing right photo.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-		delegate.controller?.showPhoto(album: self.id, photo: self.photoIds[1])
+		delegate.albumController?.showPhoto(album: self.id, photo: self.photoIds[1])
 	}