wordpress-mobile/WordPress-iOS — pull request #47 by brennanMKE (2013-08-14 22:16:05+00:00)
Title: Update to make featured image grow to full screen when tapped (plus minor clean up in other areas)

The featured image can now be tapped. It was updated to create a base class named GrowingImageView which adds a tap gesture on the image view. When tapped the image view creates another image view directly on top of itself with the same position and size though it is added to the view hierarchy at a higher level to allow it to grow in size. Tapping the full size image shrinks the newly added image and removes it once it is back to the original size. Once the image reaches full size the background color is set to black with a slight transparency so that the image is set off from the content behind it. When it starts to shrink the background color is set back to clear.

To control the full size a property was added as an outlet which must be set. An assertion ensures that this outlet is set when this class is used. That value can be set to the direct containing view but it is intended to be connected to the top view attached to the view controller to allow the image to be as big as possible. The grown image view supports rotation to and from landscape orientation. I did consider setting up an delegate to have the parent view controller provide the view to use for the full view reference but that would just add more code and more steps. Using an outlet in this way made it simpler. The assertion helps developers set it up properly.

Changes to the existing code were minimal due to creating the base class for UIImageView. The single XIB which is used for the iPad and iPhone just needed to have the base class set to GrowingImageView. It shared a view controller as well. The additional benefit of this approach is that it could be used anywhere in the app to get the same behavior. The new base class implementation is about 100 lines of code and less than 10 lines of code were added to the rest of the implementation for this change.

I did consider making the full size image pinch and zoom capable but that would have taken much more time and may not really be right for this app. I created this sort of interface before and it is in another GitHub project which mimics the features in Apple's Photos app. That is really meant more for a photo album interface and adding it here would have likely introduced complexity where it is best to leave it out.

https://github.com/brennanMKE/PhotoZoom

I did consider adding more gestures, like a swipe or pan gesture which is done in the Facebook and other apps, but those are meant for displaying photos in a stream like an album so it did not seem appropriate here. The simplicity of tapping to grow and shrink the image seemed to be the best approach even if additional gestures could be added.

Difficulties with this implementation involve the usual trouble with iOS view geometry. Getting a reliable value back from using convertPoint was not possible so the value that is used had to be adjusted by what was returned. I created a simple app to test out this base class of UIImageView but the geometry in that app behaved differently than the WP app due to targeting iOS 6 instead of iOS 5 as a baseline. Adjustments after thorough testing may be needed. With the iPad it appears to be offset from the original image's position, for example. At the moment it behaves well on the iPhone in the Simulator and on the device. Orientation changes due to rotating the device behaves well as does growing the image in portrait and landscape orientation.

I also made some other changes mostly to clean up formatting and a spelling correction. The Pod module for WordPressApi was showing the warning you get when using AFNetworking so I fixed it be updating it's pre-compiled header.