Last active
August 29, 2015 14:08
-
-
Save spraveenk91/f8287c85d4d54414754d to your computer and use it in GitHub Desktop.
Flow
This file contains hidden or 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
CustomAction.h | |
-------------- | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@protocol BaseDelegate <NSObject> | |
@required | |
- (void)didSelectActionSheetIndex:(NSString *)actionTitle actionSheetIndex:(NSInteger )index; | |
@end | |
@interface CustomAction : NSObject <UIActionSheetDelegate> | |
@property (nonatomic, strong) id<BaseDelegate> delegate; | |
@end | |
---------------------------------------------------------------------------------------------------------------- | |
CustomAction.m | |
-------------- | |
#import "CustomAction.h" | |
@implementation CustomAction | |
#pragma mark - UIActionSheet Delegate | |
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { | |
if ([[self delegate] respondsToSelector:@selector(didSelectActionSheetIndex:actionSheetIndex:)]) { | |
[[self delegate] didSelectActionSheetIndex:[actionSheet buttonTitleAtIndex:buttonIndex] actionSheetIndex:buttonIndex]; | |
} | |
} | |
- (void)actionSheetCancel:(UIActionSheet *)actionSheet { | |
NSLog(@"Dismissed"); | |
} | |
@end | |
--------------------------------------------------------------------------------------------------------------- | |
FirstViewController.m | |
--------------------- | |
#pragma mark - BaseViewController Delegate | |
- (void)didSelectActionSheetIndex:(NSString *)actionTitle actionSheetIndex:(NSInteger)index { | |
// NSLog(@"Text - %@", actionTitle); | |
switch (index) { | |
case 0: { | |
[self performSegueWithIdentifier:@"allmoviesSegue" sender:nil]; | |
} | |
break; | |
case 1: { | |
} | |
break; | |
case 2: { | |
[self performSegueWithIdentifier:@"filterSegue" sender:nil]; | |
} | |
break; | |
default: | |
break; | |
} | |
} | |
- (void)cellMenuClicked:(id)sender { | |
CustomAction *obj = [[CustomAction alloc] init]; | |
obj.delegate = self; | |
thumbActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:obj cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Add to Watchlist", @"Share", nil]; | |
[thumbActionSheet showInView:[self.view window]]; | |
} | |
--------------------------------------------------------------------------------------------------------------- | |
BaseViewController.h | |
--------------------- | |
@interface BaseViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate, UIActionSheetDelegate> | |
- (void)menuMore; | |
@end | |
BaseViewController.m | |
-------------------- | |
... | |
... | |
#pragma mark - UIActionSheet Delegate | |
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { | |
// if ([[self delegate] respondsToSelector:@selector(didSelectActionSheetIndex:actionSheetIndex:)]) { | |
// [[self delegate] didSelectActionSheetIndex:[actionSheet buttonTitleAtIndex:buttonIndex] actionSheetIndex:buttonIndex]; | |
// } | |
} | |
- (void)actionSheetCancel:(UIActionSheet *)actionSheet { | |
NSLog(@"Dismissed"); | |
} | |
#pragma mark - Actions | |
- (void)searchPage { | |
} | |
- (void)menuMore { | |
// What to create here | |
} | |
#pragma mark - View Lifecycle | |
- (void)viewWillAppear:(BOOL)animated { | |
[super viewWillAppear:animated]; | |
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[self customBarButton:[UIImage imageNamed:@"option"] targetMethod:@selector(showMenuView)]]; | |
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:[[UIBarButtonItem alloc] initWithCustomView:[self customBarButton:[UIImage imageNamed:@"more"] targetMethod:@selector(menuMore)]], FIXED_SPACE, [[UIBarButtonItem alloc] initWithCustomView:[self customBarButton:[UIImage imageNamed:@"searchicon"] targetMethod:@selector(searchPage)]], nil]; | |
} | |
... | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment