Created
May 13, 2011 16:52
-
-
Save r-plus/970872 to your computer and use it in GitHub Desktop.
これでActionSheetのボタン押すと落ちるのはなんでだ。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import "ActionMenu.h" | |
@interface ActionMenuMapsPlugin : NSObject <UIActionSheetDelegate> @end | |
@implementation ActionMenuMapsPlugin | |
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex | |
{ | |
} | |
@end | |
@implementation UIView (Maps) | |
- (void)doMaps:(id)sender | |
{ | |
//NSString *selection = [self selectedTextualRepresentation]; | |
ActionMenuMapsPlugin *tmp = [[ActionMenuMapsPlugin alloc] init]; | |
UIActionSheet *sheet = [[[UIActionSheet alloc] initWithTitle:@"Send to" | |
delegate:tmp | |
cancelButtonTitle:@"cancel" | |
destructiveButtonTitle:nil | |
otherButtonTitles:@"Maps", nil] | |
autorelease]; | |
[sheet showInView:self]; | |
[tmp release]; | |
} | |
- (BOOL)canDoMaps:(id)sender | |
{ | |
return [self respondsToSelector:@selector(insertText:)]; | |
} | |
+ (void)load | |
{ | |
static BOOL isPad; | |
NSString* model = [[UIDevice currentDevice] model]; | |
isPad = [model isEqualToString:@"iPad"]; | |
id<AMMenuItem> mapsMenu = [[UIMenuController sharedMenuController] registerAction:@selector(doMaps:) title:@"Maps" canPerform:@selector(canDoMaps:)]; | |
if (!isPad && [[UIScreen mainScreen] scale] == 2.0 ) { | |
mapsMenu.image = [[UIImage alloc] initWithContentsOfFile:@"/Library/ActionMenu/Plugins/Maps@2x.png"]; | |
} else { | |
mapsMenu.image = [[UIImage alloc] initWithContentsOfFile:@"/Library/ActionMenu/Plugins/Maps.png"]; | |
} | |
} | |
@end | |
// vim:ft=objc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment