Skip to content

Commit

Permalink
Implemented segue from table master to modal view controller on iPad.
Browse files Browse the repository at this point in the history
  • Loading branch information
mangoldm committed May 5, 2012
1 parent d10c3c7 commit 5a5c240
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 36 deletions.
1 change: 1 addition & 0 deletions PhotoMap/PhotosTableViewController.h
Expand Up @@ -24,5 +24,6 @@
@interface PhotosTableViewController: UITableViewController <PhotosTableViewControllerDelegate>
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *spinner;
@property (nonatomic, strong) NSArray *photos;
@property (nonatomic, strong) id chosenPhoto;
@property (nonatomic, weak) id <PhotosTableViewControllerDelegate> delegate;
@end
21 changes: 12 additions & 9 deletions PhotoMap/PhotosTableViewController.m
Expand Up @@ -16,9 +16,10 @@ @interface PhotosTableViewController () <MapViewControllerDelegate>
@end

@implementation PhotosTableViewController
@synthesize spinner = _spinner;
@synthesize photos = _photos;
@synthesize delegate = _delegate;
@synthesize spinner = _spinner;
@synthesize photos = _photos;
@synthesize chosenPhoto = _chosenPhoto;
@synthesize delegate = _delegate;

#define RECENT_PHOTOS_KEY @"ScrollingPhotoViewController.Recent"

Expand Down Expand Up @@ -70,6 +71,11 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
mapVC.annotations = [self mapAnnotations];
mapVC.delegate = self;
mapVC.title = self.title;
} else {
if ([segue.identifier isEqualToString: @"Show Image For Photo Annotation"] ||
[segue.identifier isEqualToString: @"Show Image From Table"]) {
[segue.destinationViewController viewController:self chosePhoto:self.chosenPhoto];
}
}
}

Expand Down Expand Up @@ -135,15 +141,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// send chosen photo to delegate
if (self.splitViewController) {
if (self.splitViewController) { // if on iPad
UINavigationController *detailNav = [self.splitViewController.viewControllers lastObject];
id detail = [detailNav.viewControllers lastObject];
if ([detail isKindOfClass:[MapViewController class]]) {
ScrollingPhotoViewController *scrollingPVC = [[ScrollingPhotoViewController alloc] init];
id photo = [self.photos objectAtIndex:indexPath.row];
scrollingPVC.chosenPhoto = photo;
self.delegate = scrollingPVC;
[detailNav pushViewController:scrollingPVC animated:YES];
self.chosenPhoto = [self.photos objectAtIndex:indexPath.row];
[self performSegueWithIdentifier:@"Show Image From Table" sender:self];
}
} else {
id photo = [self.photos objectAtIndex:indexPath.row];
Expand Down
32 changes: 5 additions & 27 deletions PhotoMap/en.lproj/MainStoryboard_iPad.storyboard
Expand Up @@ -48,7 +48,7 @@
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="1097" y="192"/>
<point key="canvasLocation" x="1161" y="394"/>
</scene>
<!--Map View Controller - Map-->
<scene sceneID="Guw-u6-0rb">
Expand Down Expand Up @@ -181,6 +181,7 @@
<navigationItem key="navigationItem" title="Place Recents" id="hSr-N2-R5m"/>
<connections>
<outlet property="spinner" destination="WsH-tU-qEa" id="Sq8-kV-rw3"/>
<segue destination="8OC-qW-Jjz" kind="modal" identifier="Show Image From Table" modalPresentationStyle="formSheet" modalTransitionStyle="flipHorizontal" id="syE-6f-fM9"/>
</connections>
</tableViewController>
</objects>
Expand Down Expand Up @@ -329,35 +330,12 @@
<image name="clock.png" width="26" height="26"/>
<image name="world.png" width="26" height="26"/>
</resources>
<classes>
<class className="MapViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/MapViewController.h"/>
<relationships>
<relationship kind="outlet" name="mapView" candidateClass="MKMapView"/>
</relationships>
</class>
<class className="PhotosTableViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/PhotosTableViewController.h"/>
<relationships>
<relationship kind="outlet" name="spinner" candidateClass="UIActivityIndicatorView"/>
</relationships>
</class>
<class className="PlacesTableViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/PlacesTableViewController.h"/>
</class>
<class className="ScrollingPhotoViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/ScrollingPhotoViewController.h"/>
<relationships>
<relationship kind="action" name="dismissPhoto:" candidateClass="UITapGestureRecognizer"/>
<relationship kind="outlet" name="imageView" candidateClass="UIImageView"/>
<relationship kind="outlet" name="scrollView" candidateClass="UIScrollView"/>
<relationship kind="outlet" name="spinner" candidateClass="UIActivityIndicatorView"/>
</relationships>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
<inferredMetricsTieBreakers>
<segue reference="syE-6f-fM9"/>
</inferredMetricsTieBreakers>
</document>

0 comments on commit 5a5c240

Please sign in to comment.