Skip to content

Instantly share code, notes, and snippets.

@r-plus
Created May 13, 2011 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-plus/970872 to your computer and use it in GitHub Desktop.
Save r-plus/970872 to your computer and use it in GitHub Desktop.
これでActionSheetのボタン押すと落ちるのはなんでだ。
#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