From d5fc6aaf489e52f27f1dfa4753afb6bb06b6b518 Mon Sep 17 00:00:00 2001 From: Ram Kola Date: Fri, 28 Oct 2011 15:49:28 +0800 Subject: [PATCH] Fixed issue with popover controller in iPad Changed the SegmentedControl on the keyboard accessory to buttons. Buttons are necessary to anchor the Pop-over controller in iPad Closes #23, closes #45 --- Classes/ActionSheetPicker.h | 1 + Classes/ActionSheetPicker.m | 9 +- Classes/TaskEditViewController.h | 1 + Classes/TaskEditViewController.m | 55 +++++----- Classes/todo_txt_touch_iosAppDelegate.h | 2 + Classes/todo_txt_touch_iosAppDelegate.m | 1 + TaskEditAccessoryView.xib | 137 +++++++++++------------- alert_white.png | Bin 0 -> 4952 bytes 8 files changed, 107 insertions(+), 99 deletions(-) create mode 100644 alert_white.png diff --git a/Classes/ActionSheetPicker.h b/Classes/ActionSheetPicker.h index eae5187..8fd625f 100755 --- a/Classes/ActionSheetPicker.h +++ b/Classes/ActionSheetPicker.h @@ -13,6 +13,7 @@ #import #import "MBProgressHUD.h" +#import "todo_txt_touch_iosAppDelegate.h" @interface ActionSheetPicker : NSObject { diff --git a/Classes/ActionSheetPicker.m b/Classes/ActionSheetPicker.m index 717e471..c1b32fc 100755 --- a/Classes/ActionSheetPicker.m +++ b/Classes/ActionSheetPicker.m @@ -54,7 +54,7 @@ + (void)showHUDWithCustomView:(UIView *)view withMessage:(NSString *)message { // The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/ // Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators) - HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease]; + HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"alert_white.png"]] autorelease]; // Set custom view mode HUD.mode = MBProgressHUDModeCustomView; @@ -167,7 +167,12 @@ - (void)showActionPicker { viewController.view = view; viewController.contentSizeForViewInPopover = viewController.view.frame.size; _popOverController = [[UIPopoverController alloc] initWithContentViewController:viewController]; - [self.popOverController presentPopoverFromRect:self.view.frame inView:self.view.superview?:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; + + //The clicked button is saved into the appdelegate. The Popover is anchored to that. + todo_txt_touch_iosAppDelegate *appdelegate = [[UIApplication sharedApplication] delegate]; + [self.popOverController presentPopoverFromBarButtonItem:appdelegate.lastClickedButton + permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES]; + } else { //spawn actionsheet _actionSheet = [[UIActionSheet alloc] initWithTitle:[self isViewPortrait]?nil:@"\n\n\n" delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; diff --git a/Classes/TaskEditViewController.h b/Classes/TaskEditViewController.h index 9d71c3f..c1492b4 100644 --- a/Classes/TaskEditViewController.h +++ b/Classes/TaskEditViewController.h @@ -79,6 +79,7 @@ - (IBAction)doneButtonPressed:(id)sender; - (IBAction)helpButtonPressed:(id)sender; - (IBAction)segmentControlPressed:(id)sender; +- (IBAction) keyboardAccessoryButtonPressed:(id)sender; - (void) addEditTask; @end diff --git a/Classes/TaskEditViewController.m b/Classes/TaskEditViewController.m index 746682d..b40d019 100644 --- a/Classes/TaskEditViewController.m +++ b/Classes/TaskEditViewController.m @@ -259,38 +259,43 @@ - (void) contextWasSelected:(NSNumber *)selectedIndex:(id)element { [textView becomeFirstResponder]; } -- (IBAction)segmentControlPressed:(id)sender { - [textView resignFirstResponder]; - - id taskBag = [todo_txt_touch_iosAppDelegate sharedTaskBag]; - UISegmentedControl *segmentedControl = (UISegmentedControl *)sender; +- (IBAction) keyboardAccessoryButtonPressed:(id)sender { - switch (segmentedControl.selectedSegmentIndex) { - case 0: // Priority - [ActionSheetPicker displayActionPickerWithView:self.view - data:[Priority allCodes] - selectedIndex:0 - target:self - action:@selector(priorityWasSelected::) - title:@"Select Priority"]; - break; - case 1: // Project - [ActionSheetPicker displayActionPickerWithView:self.view - data:[taskBag projects] - selectedIndex:0 - target:self - action:@selector(projectWasSelected::) - title:@"Select Project"]; - break; - case 2: // Context + id taskBag = [todo_txt_touch_iosAppDelegate sharedTaskBag]; + + if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + //For ipad, we have ample space and it is not necessary to hide the keyboard + todo_txt_touch_iosAppDelegate *appdelegate = [[UIApplication sharedApplication] delegate]; + appdelegate.lastClickedButton = sender; + } else { + [textView resignFirstResponder]; + } + + UIBarButtonItem *button = (UIBarButtonItem*)sender; + + if([button.title isEqualToString:@"Context"]) { // Context [ActionSheetPicker displayActionPickerWithView:self.view data:[taskBag contexts] selectedIndex:0 target:self action:@selector(contextWasSelected::) title:@"Select Context"]; - break; - } + } else if([button.title isEqualToString:@"Priority"]) { // Priority + [ActionSheetPicker displayActionPickerWithView:self.view + data:[Priority allCodes] + selectedIndex:0 + target:self + action:@selector(priorityWasSelected::) + title:@"Select Priority"]; + + } else if([button.title isEqualToString:@"Project"]) { // Priority + [ActionSheetPicker displayActionPickerWithView:self.view + data:[taskBag projects] + selectedIndex:0 + target:self + action:@selector(projectWasSelected::) + title:@"Select Project"]; + } } diff --git a/Classes/todo_txt_touch_iosAppDelegate.h b/Classes/todo_txt_touch_iosAppDelegate.h index ed1997e..3d3e168 100644 --- a/Classes/todo_txt_touch_iosAppDelegate.h +++ b/Classes/todo_txt_touch_iosAppDelegate.h @@ -62,6 +62,7 @@ UINavigationController *navigationController; id taskBag; RemoteClientManager *remoteClientManager; + id lastClickedButton; //Anchor holder for the Popover in iPad } @property (nonatomic, retain) IBOutlet UIWindow *window; @@ -69,6 +70,7 @@ @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; @property (nonatomic, readonly) id taskBag; @property (nonatomic, readonly) RemoteClientManager *remoteClientManager; +@property (nonatomic, retain) id lastClickedButton; - (void) syncClient; - (void) syncClientForceChoice:(BOOL)forceChoice; diff --git a/Classes/todo_txt_touch_iosAppDelegate.m b/Classes/todo_txt_touch_iosAppDelegate.m index 4b8dbe6..94b0fad 100644 --- a/Classes/todo_txt_touch_iosAppDelegate.m +++ b/Classes/todo_txt_touch_iosAppDelegate.m @@ -64,6 +64,7 @@ @implementation todo_txt_touch_iosAppDelegate @synthesize navigationController; @synthesize taskBag; @synthesize remoteClientManager; +@synthesize lastClickedButton; #pragma mark - diff --git a/TaskEditAccessoryView.xib b/TaskEditAccessoryView.xib index 618b7fa..705dfa2 100644 --- a/TaskEditAccessoryView.xib +++ b/TaskEditAccessoryView.xib @@ -12,10 +12,9 @@ YES - IBUIBarButtonItem - IBUIToolbar - IBUISegmentedControl IBProxyObject + IBUIToolbar + IBUIBarButtonItem YES @@ -41,64 +40,31 @@ 266 - - YES - - - 292 - {{6, 8}, {197, 30}} - - - - NO - IBCocoaTouchFramework - 2 - 3 - - YES - Priority - Project - Context - - - YES - - - - - - YES - - - - - - YES - {0, 0} - {0, 0} - {0, 0} - - - YES - - - - - YES - - {320, 44} - + NO NO IBCocoaTouchFramework YES - + + Priority IBCocoaTouchFramework - + 1 + + + + Project + IBCocoaTouchFramework + 1 + + + + Context + IBCocoaTouchFramework + 1 @@ -136,12 +102,27 @@ - segmentControlPressed: - + keyboardAccessoryButtonPressed: + - 13 - 12 + 14 + + + + keyboardAccessoryButtonPressed: + + + + 17 + + + + keyboardAccessoryButtonPressed: + + + + 18 @@ -170,8 +151,10 @@ YES - + + + @@ -181,22 +164,23 @@ - 8 - - - YES - - + 10 + - 7 - - + 13 + + - 10 - + 15 + + + + + 16 + @@ -208,10 +192,11 @@ -1.CustomClassName -2.CustomClassName 10.IBPluginDependency + 13.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency 4.IBPluginDependency 5.IBPluginDependency - 7.IBPluginDependency - 7.IUISegmentedControlInspectorSelectedSegmentMetadataKey YES @@ -221,7 +206,8 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -236,7 +222,7 @@ - 12 + 18 @@ -251,6 +237,7 @@ cancelButtonPressed: doneButtonPressed: helpButtonPressed: + keyboardAccessoryButtonPressed: segmentControlPressed: @@ -259,6 +246,7 @@ id id id + id @@ -268,6 +256,7 @@ cancelButtonPressed: doneButtonPressed: helpButtonPressed: + keyboardAccessoryButtonPressed: segmentControlPressed: @@ -284,6 +273,10 @@ helpButtonPressed: id + + keyboardAccessoryButtonPressed: + id + segmentControlPressed: id diff --git a/alert_white.png b/alert_white.png new file mode 100644 index 0000000000000000000000000000000000000000..5c1c92398599c533bf28ac6f609b29132d89596b GIT binary patch literal 4952 zcmV-e6Q}HnP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+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