Theatre, War, and Peace in Uganda | Acting Together on the World Stage | Peacebuilding and the Arts | Brandeis University
In "Theatre, War, and Peace in Uganda," playwright and scholar Charles Mulekwa discusses the important role theatre artists have played to decry the conditions of war and oppression and express the people's longing for peace. He highlights two contemporary Ugandan playwrights and places their work within the country's rich history of performance, from ancient indigenous rituals to colonial infusion of Shakespeare to politically charged, post-colonial work. Mulekwa believes that the most powerful theatre in Uganda today draws on both indigenous and western forms to speak to the deepest sorrows and hopes of a nation disrupted by colonialism, dictatorship, and war for more than a century.
Welcome to the second part of my tutorial series “Creating An Image Gallery Like Over”. In this part of the tutorial, you will learn how to actually display the photos in the UICollectionView as well as give the user the ability to take photos with their camera.
Next, open the size inspector, change the size to Custom, the width to 104 and the height to 104. This will give us nice sized images, with a good amount of padding between them.
The final step here is to drag a UIImageView on to your cell (scaling it to fit the entire cell size), and hook up the IBOutlet to the photoImageView. Do this by control-click and dragging from Photo Cell to the ImageView and selecting photoImageView.
Now, head down to the collectionView:cellForItemAtIndexPath method and replace the contents of it with the following code:
</strong>While, this is definitely cool, you might now be wondering “how do I select a photo?”. Great question, and here is the solution.
Now that you have all of the groundwork in place, selecting photos from the collection could not be easier. Open up ViewController.m and replace the collectionView:didSelectItemAtIndexPath method with the following code:
This will get the selected asset and convert it to a UIImage. You are now free to use the UIImage how you want. Perhaps you create a protocol for this class and make a callback to a delegate OR maybe you add this to a UINavigationController stack and push a new view controller on to the stack containing this image. The sky is the limit!
If you look at the Over app and back to your image gallery that you just created, you will notice something is still missing. What if the user wants to take a photo or access other albums? This is where Over adds a bar across the top of the interface with 2 buttons that fall back to the “default” style of fetching images if the user wants to take a photo or access a different photo album. Let’s build this out now.
We don’t need to add the code yet since we still need to build the UI and hook up the IBOutlets. Now open MainStoryboard.storyboard and drag a UIView right on top of your UIView.
One issue you might run in to here is the view will want to become a subview of the collection view. To combat this, drag the view outside of the collection view inside the left bar so the hierarchy will look like this:
One other “gotcha” is, you must ensure that the view is positioned below the collection view in this list, otherwise it won’t show above it on screen.
Now, let’s manually size and position the view as Interface Building will make things hard on us if we want to position it over our collection view.
Again, remember this positioning is optimized for the iPhone 5. So make sure you are testing with that simulator or you won’t see this bar.
After this, the bar still won’t be visible inside of Interface Builder. We need to set the background color to black with some transparency. Open the Attributes Inspector and click on the background color. Then set the color to black with 80% opacity:
Now drag a UIButton on to the view you just created. There are a few things that must be done to style the button:
Now, hook up the IBAction by opening the Connections Inspector and dragging from Touch Up Inside to the View Controller object and selecting takePhotoButtonTapped:
Finally, duplicate this button (copy and paste), rename the title to “Albums”, move it next to the “Take Photo” button and hook its Touch Up Inside to albumsButtonTapped:
The final step for this tutorial is to implement the code to bring up the camera as well as bring up the photo albums. Let’s start with the camera. Open ViewController.m and add the following code to the takePhotosButtonTapped: method:
Makes sure that the photo library is available. If the user declines photo access, this will be the case.
The method to bring up the photo albums is almost identical to the method above. Add the following code to the albumsButtonTapped: method.
As I said before, this method is almost identical with the only difference being, we are using UIImagePickerControllerSourceTypePhotoLibrary to open up the photo albums.
Build and Run and tap the “Take Photo” button. Make sure you are testing on the device at this stage or nothing will happen since the simulator doesn’t have a camera. You can however test the “Albums” button assuming you have some photos in your photo library.
Now that you are able to pick a photo, you need to be able to access the photo that was selected or taken. To do this implement the following delegate method for UIImagePickerController.
This method fetches the selected (or taken) image and stores. It then dismisses the camera or photo albums allowing you to do whatever is needed with the image.
By now, you should have learned how to use the ALAssets library to interact with a user’s photos and use them to build a custom interface. You also learned how to use a UICollectionView to display a grid of photos.
With this knowledge in hand, you should now be able to make much more interesting photo selection interfaces than the default one Apple has to offer. Other apps like Google+ and Instagram both have very slick photo pickers and I hope this tutorial has your gears going thinking about other interesting photo selection interfaces.