diff --git a/samples/Scrumptious/ReadMe.txt b/samples/Scrumptious/ReadMe.txt index 32ce285b59..597c7b6d96 100644 --- a/samples/Scrumptious/ReadMe.txt +++ b/samples/Scrumptious/ReadMe.txt @@ -2,14 +2,12 @@ Scrumptious sample Scrumptious demonstrates a "real-world" (albeit very limited) application that integrates with Facebook. It allows a user to select from a small pre-defined list of cuisine types that they are eating, then -tag friends who they are with, tag the restaurant they are in, and upload a photo (or take a new one) -showing their meal. Scrumptious then allows them to post an Open Graph Action to their Timeline which will -display the picture as well as the tagged friends and location. +tag friends who they are with, and tag the restaurant they are in. Scrumptious then allows them to post an +Open Graph Action to their Timeline which will display the the tagged friends and location. The example demonstrates login/logout behavior, use of the FBFriendPickerViewController and FBPlacePickerViewController, -uploading photos to Facebook, as well as the use of Open Graph objects and actions. While the functionality -is quite constrained in order to be of reasonable size for a sample, the Facebook integration could serve as the -basis for more full-featured applications. +as well as the use of Open Graph objects and actions. While the functionality is quite constrained in order to be of +reasonable size for a sample, the Facebook integration could serve as the basis for more full-featured applications. If using Scrumptious as the basis for another application, please note that all of the Open Graph namespaces will need to be updated, and a hosted service must be provided in order to serve up Open Graph Objects. In addition, the logged-in diff --git a/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj b/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj index e8fd96f586..40b9f823e2 100644 --- a/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj +++ b/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 846809C1158F85A100F2DBB9 /* action-eating.png in Resources */ = {isa = PBXBuildFile; fileRef = 846809BD158F85A100F2DBB9 /* action-eating.png */; }; 846809C2158F85A100F2DBB9 /* action-location.png in Resources */ = {isa = PBXBuildFile; fileRef = 846809BE158F85A100F2DBB9 /* action-location.png */; }; 846809C3158F85A100F2DBB9 /* action-people.png in Resources */ = {isa = PBXBuildFile; fileRef = 846809BF158F85A100F2DBB9 /* action-people.png */; }; - 846809C4158F85A100F2DBB9 /* action-photo.png in Resources */ = {isa = PBXBuildFile; fileRef = 846809C0158F85A100F2DBB9 /* action-photo.png */; }; 84A5DA9615A68A3D00FE54AF /* Accounts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84A5DA9515A68A3D00FE54AF /* Accounts.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 8527EC6815C9DB3800660673 /* Scrumptious.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8527EC6A15C9DB3800660673 /* Scrumptious.strings */; }; 8534B4DF15CC657900348ED2 /* FBUserSettingsViewResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8534B4DE15CC657900348ED2 /* FBUserSettingsViewResources.bundle */; }; @@ -37,15 +36,12 @@ B9CD0A9A150EBFFB00560A93 /* facebook.png in Resources */ = {isa = PBXBuildFile; fileRef = B9CD0A99150EBFFB00560A93 /* facebook.png */; }; DD55EAAF15AB9EDF000A64B8 /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD55EAAE15AB9EDF000A64B8 /* FacebookSDK.framework */; }; DD55EAB115ABA246000A64B8 /* FacebookSDKResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DD55EAB015ABA246000A64B8 /* FacebookSDKResources.bundle */; }; - DDBF24B71590050600BAAB8F /* SCPhotoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDBF24B51590050600BAAB8F /* SCPhotoViewController.m */; }; - DDBF24B81590050600BAAB8F /* SCPhotoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDBF24B61590050600BAAB8F /* SCPhotoViewController.xib */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 846809BD158F85A100F2DBB9 /* action-eating.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "action-eating.png"; path = "scrumptious/images/action-eating.png"; sourceTree = SOURCE_ROOT; }; 846809BE158F85A100F2DBB9 /* action-location.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "action-location.png"; path = "scrumptious/images/action-location.png"; sourceTree = SOURCE_ROOT; }; 846809BF158F85A100F2DBB9 /* action-people.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "action-people.png"; path = "scrumptious/images/action-people.png"; sourceTree = SOURCE_ROOT; }; - 846809C0158F85A100F2DBB9 /* action-photo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "action-photo.png"; path = "scrumptious/images/action-photo.png"; sourceTree = SOURCE_ROOT; }; 84A5DA9515A68A3D00FE54AF /* Accounts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accounts.framework; path = System/Library/Frameworks/Accounts.framework; sourceTree = SDKROOT; }; 8527EC6915C9DB3800660673 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Scrumptious.strings; sourceTree = ""; }; 8527EC6B15C9DB4A00660673 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Scrumptious.strings; sourceTree = ""; }; @@ -80,9 +76,6 @@ B9CD0A99150EBFFB00560A93 /* facebook.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = facebook.png; path = images/facebook.png; sourceTree = ""; }; DD55EAAE15AB9EDF000A64B8 /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; DD55EAB015ABA246000A64B8 /* FacebookSDKResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FacebookSDKResources.bundle; path = ../../build/FacebookSDK.framework/Versions/A/Resources/FacebookSDKResources.bundle; sourceTree = ""; }; - DDBF24B41590050600BAAB8F /* SCPhotoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SCPhotoViewController.h; path = scrumptious/SCPhotoViewController.h; sourceTree = SOURCE_ROOT; }; - DDBF24B51590050600BAAB8F /* SCPhotoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SCPhotoViewController.m; path = scrumptious/SCPhotoViewController.m; sourceTree = SOURCE_ROOT; }; - DDBF24B61590050600BAAB8F /* SCPhotoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SCPhotoViewController.xib; path = scrumptious/SCPhotoViewController.xib; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -153,9 +146,6 @@ B9CD0A85150EA4DD00560A93 /* SCViewController.h */, B9CD0A86150EA4DD00560A93 /* SCViewController.m */, B9CD0A8B150EA4DE00560A93 /* SCViewController.xib */, - DDBF24B41590050600BAAB8F /* SCPhotoViewController.h */, - DDBF24B51590050600BAAB8F /* SCPhotoViewController.m */, - DDBF24B61590050600BAAB8F /* SCPhotoViewController.xib */, 85954AE1155889A200FABA9A /* SCProtocols.h */, 8527EC6A15C9DB3800660673 /* Scrumptious.strings */, ); @@ -182,7 +172,6 @@ 846809BD158F85A100F2DBB9 /* action-eating.png */, 846809BE158F85A100F2DBB9 /* action-location.png */, 846809BF158F85A100F2DBB9 /* action-people.png */, - 846809C0158F85A100F2DBB9 /* action-photo.png */, 856DC2171577F105001FA6A6 /* Icon-72.png */, 856DC2181577F105001FA6A6 /* Icon.png */, 856DC2191577F105001FA6A6 /* Icon@2x.png */, @@ -252,8 +241,6 @@ 846809C1158F85A100F2DBB9 /* action-eating.png in Resources */, 846809C2158F85A100F2DBB9 /* action-location.png in Resources */, 846809C3158F85A100F2DBB9 /* action-people.png in Resources */, - 846809C4158F85A100F2DBB9 /* action-photo.png in Resources */, - DDBF24B81590050600BAAB8F /* SCPhotoViewController.xib in Resources */, DD55EAB115ABA246000A64B8 /* FacebookSDKResources.bundle in Resources */, 8527EC6815C9DB3800660673 /* Scrumptious.strings in Resources */, 8534B4DF15CC657900348ED2 /* FBUserSettingsViewResources.bundle in Resources */, @@ -274,7 +261,6 @@ B9CD0A84150EA4DD00560A93 /* SCAppDelegate.m in Sources */, B9CD0A87150EA4DD00560A93 /* SCViewController.m in Sources */, B9CD0A96150EBF5400560A93 /* SCLoginViewController.m in Sources */, - DDBF24B71590050600BAAB8F /* SCPhotoViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/Scrumptious/scrumptious/SCAppDelegate.m b/samples/Scrumptious/scrumptious/SCAppDelegate.m index 5c91d53ba0..b765d72080 100644 --- a/samples/Scrumptious/scrumptious/SCAppDelegate.m +++ b/samples/Scrumptious/scrumptious/SCAppDelegate.m @@ -122,8 +122,7 @@ - (void)sessionStateChanged:(FBSession *)session } - (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { - NSArray *permissions = [NSArray arrayWithObjects:@"user_photos", nil]; - return [FBSession openActiveSessionWithReadPermissions:permissions + return [FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { [self sessionStateChanged:session state:state error:error]; diff --git a/samples/Scrumptious/scrumptious/SCPhotoViewController.h b/samples/Scrumptious/scrumptious/SCPhotoViewController.h deleted file mode 100644 index ffecccc9fc..0000000000 --- a/samples/Scrumptious/scrumptious/SCPhotoViewController.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2012 Facebook - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import -#import "SCViewController.h" - -typedef void(^ConfirmCallback)(id sender, bool confirm); - -@interface SCPhotoViewController : UIViewController - -@property (strong, nonatomic) IBOutlet UIImageView *imageView; -@property (copy, nonatomic) ConfirmCallback confirmCallback; -@property (strong, readonly) UIImage* image; - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil image:(UIImage *)anImage; -- (IBAction)confirm:(id)sender; -- (IBAction)cancel:(id)sender; - -@end diff --git a/samples/Scrumptious/scrumptious/SCPhotoViewController.m b/samples/Scrumptious/scrumptious/SCPhotoViewController.m deleted file mode 100644 index 44528861e3..0000000000 --- a/samples/Scrumptious/scrumptious/SCPhotoViewController.m +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2012 Facebook - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import "SCPhotoViewController.h" - -@interface SCPhotoViewController () - -@property (strong, readwrite) UIImage* image; - -@end - -@implementation SCPhotoViewController - -@synthesize confirmCallback = confirmCallback; -@synthesize imageView = _imageView; -@synthesize image = _image; - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil image:(UIImage *) anImage -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - self.image = anImage; - } - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - [self.imageView setImage:self.image]; -} - -- (void)viewDidUnload -{ - [super viewDidUnload]; - self.imageView = nil; - self.image = nil; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - return (interfaceOrientation == UIInterfaceOrientationPortrait); -} - -- (IBAction)confirm:(id)sender { - if (self.confirmCallback) { - self.confirmCallback(self, true); - } - [self.navigationController popViewControllerAnimated:true]; -} - -- (IBAction)cancel:(id)sender { - if (self.confirmCallback) { - self.confirmCallback(self, false); - } - [self.navigationController popViewControllerAnimated:true]; -} -@end diff --git a/samples/Scrumptious/scrumptious/SCPhotoViewController.xib b/samples/Scrumptious/scrumptious/SCPhotoViewController.xib deleted file mode 100644 index 188db57fae..0000000000 --- a/samples/Scrumptious/scrumptious/SCPhotoViewController.xib +++ /dev/null @@ -1,264 +0,0 @@ - - - - 1296 - 11E53 - 2182 - 1138.47 - 569.00 - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 1181 - - - IBUIBarButtonItem - IBUIToolbar - IBUIImageView - IBUIView - IBProxyObject - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - PluginDependencyRecalculationVersion - - - - - IBFilesOwner - IBCocoaTouchFramework - - - IBFirstResponder - IBCocoaTouchFramework - - - - 274 - - - - 274 - {320, 416} - - - - _NS:9 - - 1 - MCAwIDAAA - - 1 - NO - IBCocoaTouchFramework - - - - 266 - {{0, 416}, {320, 44}} - - - - _NS:9 - NO - NO - IBCocoaTouchFramework - 1 - - - Cancel - IBCocoaTouchFramework - 1 - - - - IBCocoaTouchFramework - - 5 - - - Confirm - IBCocoaTouchFramework - 1 - - - - - - {{0, 20}, {320, 460}} - - - - - 3 - MQA - - 2 - - - - IBCocoaTouchFramework - - - - - - - view - - - - 3 - - - - imageView - - - - 29 - - - - cancel: - - - - 26 - - - - confirm: - - - - 23 - - - - - - 0 - - - - - - 1 - - - - - - - - - -1 - - - File's Owner - - - -2 - - - - - 4 - - - - - 7 - - - - - - - - - - 9 - - - - - 8 - - - - - 28 - - - - - - - SCPhotoViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UIResponder - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - - - 29 - - - - - SCPhotoViewController - UIViewController - - id - id - - - - cancel: - id - - - confirm: - id - - - - imageView - UIImageView - - - imageView - - imageView - UIImageView - - - - IBProjectSource - ./Classes/SCPhotoViewController.h - - - - - 0 - IBCocoaTouchFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - - YES - 3 - 1181 - - diff --git a/samples/Scrumptious/scrumptious/SCViewController.h b/samples/Scrumptious/scrumptious/SCViewController.h index 851e8a3027..de77a20848 100644 --- a/samples/Scrumptious/scrumptious/SCViewController.h +++ b/samples/Scrumptious/scrumptious/SCViewController.h @@ -22,7 +22,7 @@ typedef void(^SelectItemCallback)(id sender, id selectedItem); // FBSample logic // The main UI for the application, which lets the user select a type of food, tag who they -// are with and where they are, and choose a photo for attaching to an Open Graph Action. +// are with and where they are. @interface SCViewController : UIViewController - (void)startLocationManager; diff --git a/samples/Scrumptious/scrumptious/SCViewController.m b/samples/Scrumptious/scrumptious/SCViewController.m index 3d7459e0ba..8f5dbf807c 100644 --- a/samples/Scrumptious/scrumptious/SCViewController.m +++ b/samples/Scrumptious/scrumptious/SCViewController.m @@ -17,13 +17,11 @@ #import "SCViewController.h" #import "SCAppDelegate.h" #import "SCLoginViewController.h" -#import "SCPhotoViewController.h" #import "SCProtocols.h" #import #import "TargetConditionals.h" @interface SCViewController() < UITableViewDataSource, - UIImagePickerControllerDelegate, FBFriendPickerDelegate, UINavigationControllerDelegate, FBPlacePickerDelegate, @@ -35,20 +33,14 @@ @interface SCViewController() < UITableViewDataSource, @property (strong, nonatomic) IBOutlet UILabel *userNameLabel; @property (strong, nonatomic) IBOutlet UIButton *announceButton; @property (strong, nonatomic) IBOutlet UITableView *menuTableView; -@property (strong, nonatomic) UIImagePickerController *imagePicker; -@property (strong, nonatomic) UIActionSheet *imagePickerActionSheet; @property (strong, nonatomic) UIActionSheet *mealPickerActionSheet; @property (retain, nonatomic) NSArray *mealTypes; @property (strong, nonatomic) NSObject *selectedPlace; @property (strong, nonatomic) NSString *selectedMeal; @property (strong, nonatomic) NSArray *selectedFriends; -@property (strong, nonatomic) UIImage *selectedPhoto; @property (strong, nonatomic) CLLocationManager *locationManager; @property (strong, nonatomic) FBCacheDescriptor *placeCacheDescriptor; -@property (strong, nonatomic) UIPopoverController *popover; -@property (strong, nonatomic) SCPhotoViewController *photoViewController; -@property (nonatomic) CGRect popoverFromRect; @property (strong, nonatomic) UIActivityIndicatorView *activityIndicator; - (IBAction)announce:(id)sender; @@ -56,8 +48,7 @@ - (void)populateUserDetails; - (void)updateSelections; - (void)updateCellIndex:(int)index withSubtitle:(NSString *)subtitle; - (id)mealObjectForMeal:(NSString *)meal; -- (void)postPhotoThenOpenGraphAction; -- (void)postOpenGraphActionWithPhotoURL:(NSString *)photoID; +- (void)postOpenGraphAction; - (void)centerAndShowActivityIndicator; - (void)setPlaceCacheDescriptorForCoordinates:(CLLocationCoordinate2D)coordinates; @@ -70,15 +61,9 @@ @implementation SCViewController @synthesize selectedMeal = _selectedMeal; @synthesize selectedFriends = _selectedFriends; @synthesize announceButton = _announceButton; -@synthesize selectedPhoto = _selectedPhoto; -@synthesize imagePicker = _imagePicker; -@synthesize photoViewController = _photoViewController; @synthesize menuTableView = _menuTableView; @synthesize locationManager = _locationManager; -@synthesize popover = _popover; -@synthesize imagePickerActionSheet = _imagePickerActionSheet; @synthesize mealPickerActionSheet = _mealPickerActionSheet; -@synthesize popoverFromRect = _popoverFromRect; @synthesize activityIndicator = _activityIndicator; @synthesize settingsViewController = _settingsViewController; @synthesize mealTypes = _mealTypes; @@ -119,8 +104,8 @@ @implementation SCViewController } // FBSample logic -// Creates the Open Graph Action with an optional photo URL. -- (void)postOpenGraphActionWithPhotoURL:(NSString *)photoURL { +// Creates the Open Graph Action. +- (void)postOpenGraphAction { // First create the Open Graph meal object for the meal we ate. id mealObject = [self mealObjectForMeal:self.selectedMeal]; @@ -139,15 +124,6 @@ - (void)postOpenGraphActionWithPhotoURL:(NSString *)photoURL { if (self.selectedFriends.count > 0) { [action setObject:self.selectedFriends forKey:@"tags"]; } - if (photoURL) { - NSMutableDictionary *image = [[NSMutableDictionary alloc] init]; - [image setObject:photoURL forKey:@"url"]; - - NSMutableArray *images = [[NSMutableArray alloc] init]; - [images addObject:image]; - - action.image = images; - } // Create the request and post the action to the "me/fb_sample_scrumps:eat" path. [FBRequestConnection startForPostWithGraphPath:@"me/fb_sample_scrumps:eat" @@ -167,7 +143,6 @@ - (void)postOpenGraphActionWithPhotoURL:(NSString *)photoURL { self.selectedMeal = nil; self.selectedPlace = nil; self.selectedFriends = nil; - self.selectedPhoto = nil; [self updateSelections]; } else { alertText = [NSString stringWithFormat:@"error: domain = %@, code = %d", @@ -183,41 +158,7 @@ - (void)postOpenGraphActionWithPhotoURL:(NSString *)photoURL { } // FBSample logic -// Creates an Open Graph Action using the user-specified properties, optionally first -// uploading a photo to Facebook and attaching it to the action. -- (void)postPhotoThenOpenGraphAction { - FBRequestConnection *connection = [[FBRequestConnection alloc] init]; - - // First request uploads the photo. - FBRequest *request1 = [FBRequest requestForUploadPhoto:self.selectedPhoto]; - [connection addRequest:request1 - completionHandler: - ^(FBRequestConnection *connection, id result, NSError *error) { - if (!error) { - } - } - batchEntryName:@"photopost" - ]; - - // Second request retrieves photo information for just-created photo so we can grab its source. - FBRequest *request2 = [FBRequest requestForGraphPath:@"{result=photopost:$.id}"]; - [connection addRequest:request2 - completionHandler: - ^(FBRequestConnection *connection, id result, NSError *error) { - if (!error && - result) { - NSString *source = [result objectForKey:@"source"]; - [self postOpenGraphActionWithPhotoURL:source]; - } - } - ]; - - [connection start]; -} - -// FBSample logic -// Handles the user clicking the Announce button, by either creating an Open Graph Action -// or first uploading a photo and then creating the action. +// Handles the user clicking the Announce button by creating an Open Graph Action - (IBAction)announce:(id)sender { // if we don't have permission to announce, let's first address that if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) { @@ -235,12 +176,7 @@ - (IBAction)announce:(id)sender { [self centerAndShowActivityIndicator]; [self.view setUserInteractionEnabled:NO]; - if (self.selectedPhoto) { - self.selectedPhoto = [self normalizedImage:self.selectedPhoto]; - [self postPhotoThenOpenGraphAction]; - } else { - [self postOpenGraphActionWithPhotoURL:nil]; - } + [self postOpenGraphAction]; } } @@ -254,32 +190,6 @@ - (void)centerAndShowActivityIndicator { self.activityIndicator.center = center; [self.activityIndicator startAnimating]; } -#pragma mark UIImagePickerControllerDelegate methods - -- (void)imagePickerController:(UIImagePickerController *)picker - didFinishPickingImage:(UIImage *)image - editingInfo:(NSDictionary *)editingInfo { - - if (!self.photoViewController) { - __block SCViewController *myself = self; - self.photoViewController = [[SCPhotoViewController alloc]initWithNibName:@"SCPhotoViewController" bundle:nil image:image]; - self.photoViewController.confirmCallback = ^(id sender, bool confirm) { - if(confirm) { - myself.selectedPhoto = image; - } - [myself updateSelections]; - }; - } - [self.navigationController pushViewController:self.photoViewController animated:true]; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [self.popover dismissPopoverAnimated:YES]; - } else { - [self dismissModalViewControllerAnimated:YES]; - } - self.photoViewController = nil; -} - -#pragma mark - #pragma mark UIActionSheetDelegate methods @@ -294,42 +204,6 @@ - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSIn self.selectedMeal = [self.mealTypes objectAtIndex:buttonIndex]; [self updateSelections]; - } else { // self.imagePickerActionSheet - NSAssert(actionSheet == self.imagePickerActionSheet, @"Delegate method's else-case should be for image picker"); - - if (!self.imagePicker) { - self.imagePicker = [[UIImagePickerController alloc] init]; - self.imagePicker.delegate = self; - } - - // Set the source type of the imagePicker to the users selection - if (buttonIndex == 0) { - // If its the simulator, camera is no good - if(TARGET_IPHONE_SIMULATOR){ - [[[UIAlertView alloc] initWithTitle:@"Camera not supported in simulator." - message:@"(>'_')>" - delegate:nil - cancelButtonTitle:@"Ok" - otherButtonTitles:nil] show]; - return; - } - self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; - } else if (buttonIndex == 1) { - self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; - } - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - // Can't use presentModalViewController for image picker on iPad - if (!self.popover) { - self.popover = [[UIPopoverController alloc] initWithContentViewController:self.imagePicker]; - } - [self.popover presentPopoverFromRect:self.popoverFromRect - inView:self.view - permittedArrowDirections:UIPopoverArrowDirectionAny - animated:YES]; - } else { - [self presentModalViewController:self.imagePicker animated:YES]; - } } } @@ -372,8 +246,6 @@ - (void)updateSelections { } [self updateCellIndex:2 withSubtitle:friendsSubtitle]; - [self updateCellIndex:3 withSubtitle:(self.selectedPhoto ? @"Ready" : @"Take one")]; - self.announceButton.enabled = (self.selectedMeal != nil); } @@ -394,8 +266,6 @@ - (void)populateUserDetails { - (void)dealloc { _locationManager.delegate = nil; - _imagePicker.delegate = nil; - _imagePickerActionSheet.delegate = nil; _mealPickerActionSheet.delegate = nil; } @@ -454,10 +324,6 @@ - (void)viewDidUnload { [[NSNotificationCenter defaultCenter] removeObserver:self]; // Release any retained subviews of the main view. - self.photoViewController = nil; - self.imagePicker = nil; - self.popover = nil; - self.imagePickerActionSheet = nil; self.mealPickerActionSheet = nil; } @@ -485,7 +351,7 @@ - (void)setPlaceCacheDescriptorForCoordinates:(CLLocationCoordinate2D)coordinate #pragma mark UITableViewDataSource methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 4; + return 3; } - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath @@ -529,12 +395,6 @@ - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS cell.imageView.image = [UIImage imageNamed:@"action-people.png"]; break; - case 3: - cell.textLabel.text = @"Got a picture?"; - cell.detailTextLabel.text = @"Take one"; - cell.imageView.image = [UIImage imageNamed:@"action-photo.png"]; - break; - default: break; } @@ -635,22 +495,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath }]; return; } - - case 3: - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - self.popoverFromRect = [tableView rectForRowAtIndexPath:indexPath]; - } - if(!self.imagePickerActionSheet) { - self.imagePickerActionSheet = [[UIActionSheet alloc] initWithTitle:@"" - delegate:self - cancelButtonTitle:@"Cancel" - destructiveButtonTitle:nil - otherButtonTitles:@"Take Photo", @"Choose Existing", nil]; - } - - [self.imagePickerActionSheet showInView:self.view]; - // Return rather than execute below code - return; } [self.navigationController pushViewController:target animated:YES]; @@ -679,67 +523,4 @@ - (void)locationManager:(CLLocationManager *)manager #pragma mark - -- (UIImage*) normalizedImage:(UIImage*)image { - CGImageRef imgRef = image.CGImage; - CGFloat width = CGImageGetWidth(imgRef); - CGFloat height = CGImageGetHeight(imgRef); - CGAffineTransform transform = CGAffineTransformIdentity; - CGRect bounds = CGRectMake(0, 0, width, height); - CGSize imageSize = bounds.size; - CGFloat boundHeight; - UIImageOrientation orient = image.imageOrientation; - - switch (orient) { - case UIImageOrientationUp: //EXIF = 1 - transform = CGAffineTransformIdentity; - break; - - case UIImageOrientationDown: //EXIF = 3 - transform = CGAffineTransformMakeTranslation(imageSize.width, imageSize.height); - transform = CGAffineTransformRotate(transform, M_PI); - break; - - case UIImageOrientationLeft: //EXIF = 6 - boundHeight = bounds.size.height; - bounds.size.height = bounds.size.width; - bounds.size.width = boundHeight; - transform = CGAffineTransformMakeTranslation(imageSize.height, imageSize.width); - transform = CGAffineTransformScale(transform, -1.0, 1.0); - transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0); - break; - - case UIImageOrientationRight: //EXIF = 8 - boundHeight = bounds.size.height; - bounds.size.height = bounds.size.width; - bounds.size.width = boundHeight; - transform = CGAffineTransformMakeTranslation(0.0, imageSize.width); - transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0); - break; - - default: - // image is not auto-rotated by the photo picker, so whatever the user - // sees is what they expect to get. No modification necessary - transform = CGAffineTransformIdentity; - break; - } - - UIGraphicsBeginImageContext(bounds.size); - CGContextRef context = UIGraphicsGetCurrentContext(); - - if ((image.imageOrientation == UIImageOrientationDown) || - (image.imageOrientation == UIImageOrientationRight) || - (image.imageOrientation == UIImageOrientationUp)) { - // flip the coordinate space upside down - CGContextScaleCTM(context, 1, -1); - CGContextTranslateCTM(context, 0, -height); - } - - CGContextConcatCTM(context, transform); - CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height), imgRef); - UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return imageCopy; -} - @end diff --git a/samples/Scrumptious/scrumptious/images/action-photo.png b/samples/Scrumptious/scrumptious/images/action-photo.png deleted file mode 100644 index 46533cc70f..0000000000 Binary files a/samples/Scrumptious/scrumptious/images/action-photo.png and /dev/null differ