Assignment #4 Extra Task #1

Please note, this blog entry is from a previous course. You might want to check out the current one.

Divide your list of top places into sections (in the table view sense) by country. This will require a little bit different data structure in that MVC.

To sort our places into countries we need two new properties for the data model. placesByCountry will hold the places separated into their countries. countries will just hold the names of the countries sorted alphabetically.

@property (nonatomic, strong) NSDictionary *placesByCountry;
@property (nonatomic, strong) NSArray *countries;
   ...
@synthesize placesByCountry = _placesByCountry;
@synthesize countries = _countries;

Continue reading “Assignment #4 Extra Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #4 Task #9 Addendum

Please note, this blog entry is from a previous course. You might want to check out the current one.

Your application must work in both portrait and landscape orientations on the iPhone. Support for the iPad is optional (though it will be required next week, so you can save time later by implementing it now). Use appropriate platform-specific UI idioms (e.g., you must use UINavigationControllers to present the information on the iPhone).

We start by deleting everything in the iPad storyboard and copy everything from the iPhone storyboard into the iPad storyboard. Remove the segues from the table views to the photo view controller.

Drag in a split view controller and remove its master and detail view. Instead wire up the tab bar controller as master and the photo view controller as detail view. Add a bar tool to the photo view controller and create an outlet to its class. Finally setup the split view controller as initial view controller.
Continue reading “Assignment #4 Task #9 Addendum”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #4 Task #11

Please note, this blog entry is from a previous course. You might want to check out the current one.

The list of recents photos should be saved in NSUserDefaults. The arrays you get back from the FlickrFetcher methods are all property lists.

Inside the photo view controller we set the setter for the photo model to save its data to NSUserDefaults. First we copy the existing list, or create an empty array if there is no entry yet. Using a block enumerator we loop through the array to see if the current photo is already there and remove it. Then we add the current photo data to the beginning of the array. If the array exceeds 20 items we delete the last one.
Continue reading “Assignment #4 Task #11”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #4 Task #10

Please note, this blog entry is from a previous course. You might want to check out the current one.

The recents tab must show the list of most recently view photos in chronological order of viewing with the most recent at the top, and no duplicates in the list. It is sufficient to only update the list each time it (re)appears on screen (i.e. in viewWillAppear:). A photo can be uniquely identified by its “id” entry in its dictionary.

Create a model for the recents list, holding data for the recent photos:

@property (nonatomic, strong) NSArray *photos;

Synthesize the model and set its setter to reload the table when the data has changed:
Continue reading “Assignment #4 Task #10”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #4 Task #9

Please note, this blog entry is from a previous course. You might want to check out the current one.

Your application must work in both portrait and landscape orientations on the iPhone. Support for the iPad is optional (though it will be required next week, so you can save time later by implementing it now). Use appropriate platform-specific UI idioms (e.g., you must use UINavigationControllers to present the information on the iPhone).

We start by allow auto rotation in the common-table-view-controller class and the photo-view-controller class:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

Continue reading “Assignment #4 Task #9”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #4 Task #8

Please note, this blog entry is from a previous course. You might want to check out the current one.

Whenever a photo’s image appears on screen, it should initially be zoomed to show as much of the photo as possible with no extra, unused space. It is not necessary to continue to do this as the user rotates the device or zooms in and out on the photo by pinching.

To solve that we check what the zoom scales would be when we would display the complete width or height of the image, and set the actual scale to the larger value:

    double wScale = self.scrollView.bounds.size.width / image.size.width;
    double hScale = self.scrollView.bounds.size.height / image.size.height;
    if (wScale > hScale) self.scrollView.zoomScale = wScale;
    else self.scrollView.zoomScale = hScale;

The complete code for this task is available at github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail