 
 	required init(coder aDecoder: NSCoder) {
 	    fatalError("init(coder:) has not been implemented")
+	}
+	
+	override func layoutSubviews()
+	{
+		super.layoutSubviews()
+		
+		// center the image as it becomes smaller than the size of the screen
+		if let uMainImageView = mainImageView {
+			var boundsSize = self.bounds.size
+			var frameToCenter = uMainImageView.frame
+			
+			// center horizontally
+			if frameToCenter.size.width < boundsSize.width {
+				frameToCenter.origin.x = (boundsSize.width - frameToCenter.size.width) / 2
+			}
+			else {
+				frameToCenter.origin.x = 0
+			}
+			
+			// center vertically
+			if frameToCenter.size.height < boundsSize.height {
+				frameToCenter.origin.y = (boundsSize.height - frameToCenter.size.height) / 2
+			}
+			else {
+				frameToCenter.origin.y = 0
+			}
+			
+			uMainImageView.frame = frameToCenter
+		}
 	}
 	
 	/*deinit

	}
}

let captionPadding: CGFloat = 8.0

class LBPhotoCaptionView: UIView
{

					if (error == nil && image != nil) {
						activityIndicator.removeFromSuperview()
						
						selfW.frame = CGRectMake(0, 0, image.size.width, image.size.height)
						selfW.photoItemView.contentSize = image.size
						
						selfW.photoItemView.setMaxMinZoomScalesForCurrentBounds()
						selfW.photoItemView.zoomScale = selfW.photoItemView.minimumZoomScale
						
						/*var widthScale = image.size.width / selfW.photoItemView.frame.size.width
						var heightScale = image.size.height / selfW.photoItemView.frame.size.height
						selfW.photoItemView.maximumZoomScale = min(widthScale, heightScale) * MaxZoomingScale
						selfW.frame.size.width = image.size.width
						selfW.frame.size.height = image.size.height
						selfW.center = selfW.photoItemView.center*/
					}
				})
			}
