Skip to content

Commit

Permalink
fix a bug: doneblock not working
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengting committed Nov 27, 2016
1 parent cb9356c commit 96e1fe7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -2,6 +2,8 @@
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

.DS_Store

## Build generated
build/
DerivedData
Expand Down Expand Up @@ -33,7 +35,7 @@ xcuserdata
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
Pods/

# Carthage
#
Expand Down
23 changes: 12 additions & 11 deletions FTPopMenu/FTPopMenu.h
Expand Up @@ -39,7 +39,7 @@
title:(NSString *)title
menuArray:(NSArray<NSString *> *)menuArray
menuImageNameArray:(NSArray<NSString *> *)menuImageNameArray
preferedWidth:(CGFloat )perferedWidth
perferedWidth:(CGFloat )perferedWidth
rowHeight:(CGFloat )rowHeight
tintColor:(UIColor *)tintColor
doneBlock:(void(^)(NSInteger selectedIndex))doneBlock
Expand Down Expand Up @@ -69,16 +69,17 @@
cancelBlock:(void(^)())cancelBlock;


+(void)showFTMenuForViewController:(UIViewController *)sourceViewController
fromBarButtonItem:(UIBarButtonItem *)barButtonItem
title:(NSString *)title
menuArray:(NSArray<NSString *> *)menuArray
menuImageNameArray:(NSArray<NSString *> *)menuImageNameArray
preferedWidth:(CGFloat )perferedWidth
rowHeight:(CGFloat )rowHeight
tintColor:(UIColor *)tintColor
doneBlock:(void(^)(NSInteger selectedIndex))doneBlock
cancelBlock:(void(^)())cancelBlock;
-(void)showForViewController:(UIViewController *)sourceViewController
fromBarButtonItem:(UIBarButtonItem *)barButtonItem
senderView:(UIView *)sender
title:(NSString *)title
tintColor:(UIColor *)tintColor
perferedWidth:(CGFloat )perferedWidth
rowHeight:(CGFloat )rowHeight
menuArray:(NSArray<NSString *> *)menuArray
menuImageNameArray:(NSArray<NSString *> *)menuImageNameArray
doneBlock:(void(^)(NSInteger selectedIndex))doneBlock
cancelBlock:(void(^)())cancelBlock;



Expand Down
20 changes: 10 additions & 10 deletions FTPopMenu/FTPopTableViewController.m
Expand Up @@ -202,15 +202,7 @@ - (void)popoverPresentationController:(UIPopoverPresentationController *)popover
}
- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController
{
if (_selectedIndex >= 0) {
if (self.doneBlock) {
self.doneBlock(_selectedIndex);
}
}else{
if (self.cancelBlock) {
self.cancelBlock();
}
}

}


Expand All @@ -235,7 +227,15 @@ - (UIViewController *)presentationController:(UIPresentationController *)control
- (void)dismiss {
[self dismissViewControllerAnimated:YES
completion:^{

if (_selectedIndex >= 0) {
if (self.doneBlock) {
self.doneBlock(_selectedIndex);
}
}else{
if (self.cancelBlock) {
self.cancelBlock();
}
}
}];
}

Expand Down
6 changes: 5 additions & 1 deletion FTPopMenuDemo/FTPopMenu.xcodeproj/project.pbxproj
Expand Up @@ -182,7 +182,7 @@
5A675A6E1CFAAD6B000DAC1C /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = liufengting;
TargetAttributes = {
5A675A751CFAAD6B000DAC1C = {
Expand Down Expand Up @@ -300,8 +300,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -344,8 +346,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down
34 changes: 19 additions & 15 deletions FTPopMenuDemo/FTPopMenu/ViewController.m
Expand Up @@ -55,7 +55,7 @@ - (IBAction)doneAction:(UIBarButtonItem *)sender {
[self showFTMenuFromBarButtonItem:sender
menuArray:[self menuStringArray]
doneBlock:^(NSInteger selectedIndex) {

NSLog(@"%ld",selectedIndex);
} cancelBlock:^{

}];
Expand Down Expand Up @@ -109,7 +109,8 @@ - (IBAction)showAction:(UIButton *)sender
[self showFTMenuFromView:sender
menuArray:[self menuStringArray]
doneBlock:^(NSInteger selectedIndex) {

NSLog(@"%ld",selectedIndex);

}cancelBlock:^{

}];
Expand Down Expand Up @@ -141,19 +142,22 @@ - (IBAction)showAction:(UIButton *)sender


//Class Method custom
// [FTPopMenu showFTMenuForViewController:self
// fromView:sender
// title:@"I am Title"
// menuArray:[self menuStringArray]
// menuImageNameArray:[self menuImageStringArray]
// preferedWidth:200
// rowHeight:60
// tintColor:[UIColor blackColor]
// doneBlock:^(NSInteger selectedIndex) {
//
// }cancelBlock:^{
//
// }];

// [FTPopMenu showFTMenuForViewController:self
// fromView:sender
// title:@"I am Title"
// menuArray:[self menuStringArray]
// menuImageNameArray:[self menuImageStringArray]
// perferedWidth:200
// rowHeight:60
// tintColor:[UIColor blackColor]
// doneBlock:^(NSInteger selectedIndex) {
//
// } cancelBlock:^{
//
// }];


}


Expand Down

0 comments on commit 96e1fe7

Please sign in to comment.