Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Misc Changes #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions MKAdditions/UIActionSheet+MKBlockAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@

@interface UIActionSheet (MKBlockAdditions) <UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
+(void) actionSheetWithTitle:(NSString*) title
message:(NSString*) message
buttons:(NSArray*) buttonTitles
showInView:(UIView*) view
onDismiss:(DismissBlock) dismissed
onCancel:(CancelBlock) cancelled;


+ (void) actionSheetWithTitle:(NSString*) title
message:(NSString*) message
destructiveButtonTitle:(NSString*) destructiveButtonTitle
buttons:(NSArray*) buttonTitles
showInView:(UIView*) view
Expand Down
17 changes: 8 additions & 9 deletions MKAdditions/UIActionSheet+MKBlockAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
@implementation UIActionSheet (MKBlockAdditions)

+(void) actionSheetWithTitle:(NSString*) title
message:(NSString*) message
buttons:(NSArray*) buttonTitles
showInView:(UIView*) view
onDismiss:(DismissBlock) dismissed
onCancel:(CancelBlock) cancelled
{
[UIActionSheet actionSheetWithTitle:title
message:message
destructiveButtonTitle:nil
buttons:buttonTitles
showInView:view
Expand All @@ -32,7 +30,6 @@ +(void) actionSheetWithTitle:(NSString*) title
}

+ (void) actionSheetWithTitle:(NSString*) title
message:(NSString*) message
destructiveButtonTitle:(NSString*) destructiveButtonTitle
buttons:(NSArray*) buttonTitles
showInView:(UIView*) view
Expand All @@ -46,7 +43,7 @@ + (void) actionSheetWithTitle:(NSString*) title
_dismissBlock = [dismissed copy];

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title
delegate:[self class]
delegate:(id<UIActionSheetDelegate>)[self class]
cancelButtonTitle:nil
destructiveButtonTitle:destructiveButtonTitle
otherButtonTitles:nil];
Expand Down Expand Up @@ -91,7 +88,7 @@ + (void) photoPickerWithTitle:(NSString*) title
int cancelButtonIndex = -1;

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title
delegate:[self class]
delegate:(id<UIActionSheetDelegate>)[self class]
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
Expand Down Expand Up @@ -144,14 +141,16 @@ + (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
[_presentVC dismissModalViewControllerAnimated:YES];
[picker autorelease];
[_presentVC release];
_cancelBlock();
if (_cancelBlock)
_cancelBlock();
}

+(void)actionSheet:(UIActionSheet*) actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex
{
if(buttonIndex == [actionSheet cancelButtonIndex])
{
_cancelBlock();
if (_cancelBlock)
_cancelBlock();
}
else
{
Expand All @@ -168,7 +167,7 @@ +(void)actionSheet:(UIActionSheet*) actionSheet didDismissWithButtonIndex:(NSInt


UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = [self class];
picker.delegate = (id<UINavigationControllerDelegate, UIImagePickerControllerDelegate>)[self class];
picker.allowsEditing = YES;

if(buttonIndex == 1)
Expand All @@ -182,7 +181,7 @@ +(void)actionSheet:(UIActionSheet*) actionSheet didDismissWithButtonIndex:(NSInt

[_presentVC presentModalViewController:picker animated:YES];
}
else
else if (_dismissBlock)
{
_dismissBlock(buttonIndex);
}
Expand Down