Forráskód Böngészése

All four album thumbnails shown.

Iñigo Valentin 9 éve
szülő
commit
c97c918342
3 módosított fájl, 18 hozzáadás és 18 törlés
  1. 4 15
      app/GalleryView.swift
  2. 2 3
      app/RowGallery.swift
  3. 12 0
      app/RowGallery.xib

+ 4 - 15
app/GalleryView.swift

@@ -69,28 +69,21 @@ class GalleryView: UIView {
 		do {
 			//Get the results
 			let searchResults = try context.fetch(fetchRequest)
-			
-			//I like to check the size of the returned results!
-			print ("GALLERY:DEBUG: Total albums: \(searchResults.count)")
-			
+
 			var row : RowGallery
 			var count = 0
 			var id: Int
 			var title: String
 			for r in searchResults as [NSManagedObject] {
 				count = count + 1
-				print("GALLERY:DEBUG: album perm: \(r.value(forKey: "permalink"))")
-				
 				
 				//Create a new row
 				row = RowGallery.init(s: "rowGallery\(count)", i: count)
 				id = r.value(forKey: "id")! as! Int
 				
-				print("GALLERY:DEBUG: Setting title")
 				title = r.value(forKey: "title_\(lang)")! as! String
 				row.setTitle(text: title)
 				
-				print("GALLERY:DEBUG: 1")
 				// Get 4 random images from the album
 				let imgFetchRequest: NSFetchRequest<Photo_album> = Photo_album.fetchRequest()
 				// TODO Order random
@@ -99,11 +92,11 @@ class GalleryView: UIView {
 				//simgFetchRequest.sortDescriptors = imgSortDescriptors
 				imgFetchRequest.predicate = NSPredicate(format: "album == %i", id)
 				imgFetchRequest.fetchLimit = 4
-				print("GALLERY:DEBUG: 2")
 				do{
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					
 					// Loop images
+					var imageIdx = 0
 					for imgR in imgSearchResults as [NSManagedObject]{
 						
 						let imageId = imgR.value(forKey: "photo")! as! Int
@@ -115,16 +108,13 @@ class GalleryView: UIView {
 						do{
 							let singleImgSearchResults = try context.fetch(singleImgFetchRequest)
 							
-							// Loop images
-							var imageIdx = 0
+							// Loop image
 							for sImgR in singleImgSearchResults as [NSManagedObject]{
 						
 								let image = sImgR.value(forKey: "file")! as! String
-								print ("GALLERY:DEBUG: Setting image \(imageIdx): \(image)")
 								row.setImage(idx: imageIdx, filename: image)
-						
-								imageIdx = imageIdx + 1
 							}
+							imageIdx = imageIdx + 1
 						}
 						catch {
 							print("GALLERY:ERROR: Error getting image from photo entity: \(error)")
@@ -156,7 +146,6 @@ class GalleryView: UIView {
 		for view in scrollView.subviews {
 			//contentRect = contentRect.union(view.frame);
 			h = h + Int(view.frame.height) + 30 //Why 30?
-			print("GALLERY:DEBUG: curh: \(h)")
 		}
 		// TODO: Calculate at the end
 		self.scrollView.contentSize.height = 2500//CGFloat(h);

+ 2 - 3
app/RowGallery.swift

@@ -59,7 +59,7 @@ Extension of UIView to be formatted as sections.
 	:param: i Custom identifier
 	*/
 	init(s: String, i: Int) {
-		print("ROWGALLERY:DEBUG: Init s, i")
+		print("ROWGALLERY:DEBUG: Init \(s), \(i)")
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		v = self
@@ -67,7 +67,6 @@ Extension of UIView to be formatted as sections.
 		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		v.translatesAutoresizingMaskIntoConstraints = true
 		
-		print("ROWGALLERY:DEBUG: Setting container")
 		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		container.translatesAutoresizingMaskIntoConstraints = true
 		
@@ -109,7 +108,7 @@ Extension of UIView to be formatted as sections.
 	*/
 	func setImage(idx: Int, filename: String){
 		if (filename == ""){
-			print("No image")
+			print("ROWGALLERY:LOG: No image.")
 			//TODO hide the imageview
 		}
 		else{

+ 12 - 0
app/RowGallery.xib

@@ -40,6 +40,9 @@
                                 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="ALA-B7-xYr" userLabel="Photo0">
                                     <rect key="frame" x="10" y="41" width="162.5" height="108"/>
                                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="108" id="iiK-OG-AZy"/>
+                                    </constraints>
                                     <userDefinedRuntimeAttributes>
                                         <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
                                             <color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -52,6 +55,9 @@
                                 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="1yK-KV-day" userLabel="Photo1">
                                     <rect key="frame" x="182.5" y="41" width="162.5" height="108"/>
                                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="108" id="vrH-X3-6Rl"/>
+                                    </constraints>
                                     <userDefinedRuntimeAttributes>
                                         <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
                                             <real key="value" value="1"/>
@@ -64,6 +70,9 @@
                                 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="FJP-ZD-LGA" userLabel="Photo2">
                                     <rect key="frame" x="10" y="162" width="162.5" height="108"/>
                                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="108" id="U9z-FX-Qxl"/>
+                                    </constraints>
                                     <userDefinedRuntimeAttributes>
                                         <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
                                             <color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -76,6 +85,9 @@
                                 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="Xwd-Zx-bfE" userLabel="Photo3">
                                     <rect key="frame" x="182.5" y="162" width="162.5" height="108"/>
                                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="108" id="lL5-Te-XTy"/>
+                                    </constraints>
                                     <userDefinedRuntimeAttributes>
                                         <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
                                             <color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>