Skip to content

Commit

Permalink
Revert "change showInSuperView to uiwindow"
Browse files Browse the repository at this point in the history
  • Loading branch information
Vodolazkyi authored Apr 19, 2017
1 parent 8af1ecc commit 2215ce9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
5 changes: 2 additions & 3 deletions Example/ContextMenu/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ - (IBAction)presentMenuButtonTapped:(UIBarButtonItem *)sender {
}

// it is better to use this method only for proper animation
// [self.contextMenuTableView showInView:self.navigationController.view withEdgeInsets:UIEdgeInsetsZero animated:YES];
[self.contextMenuTableView showWithAnimated:YES];
[self.contextMenuTableView showInView:self.navigationController.view withEdgeInsets:UIEdgeInsetsZero animated:YES];
}

#pragma mark - Local methods
Expand Down Expand Up @@ -144,4 +143,4 @@ - (UITableViewCell *)tableView:(YALContextMenuTableView *)tableView cellForRowAt
return cell;
}

@end
@end
2 changes: 1 addition & 1 deletion YALContextMenu/YALContextMenuTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ typedef NS_ENUM(NSInteger, MenuItemsAppearanceDirection) {
@param YES or NO weather you want appearance animated or not.
*/
- (void)showWithAnimated:(BOOL)animated;
- (void)showInView:(UIView *)superview withEdgeInsets:(UIEdgeInsets)edgeInsets animated:(BOOL)animated;

/*!
@abstract
Expand Down
22 changes: 6 additions & 16 deletions YALContextMenu/YALContextMenuTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ @interface YALContextMenuTableView ()
@property (nonatomic, strong) UITableViewCell<YALContextMenuCell> *selectedCell;
@property (nonatomic, strong) NSIndexPath *dismissalIndexpath;
@property (nonatomic) AnimatingState animatingState;
@property (nonatomic, strong) UIWindow *window;

@end

Expand All @@ -65,22 +64,15 @@ - (instancetype)init {
self.menuItemsSide = Right;
self.menuItemsAppearanceDirection = FromTopToBottom;

self.window = [[UIWindow alloc] init];
self.window.windowLevel = UIWindowLevelStatusBar + 1.0f;
self.window.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7f];
self.frame = self.window.frame;

// self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7f];
self.backgroundColor = [UIColor clearColor];
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7f];
self.separatorColor = [UIColor colorWithRed:181.0/255.0 green:181.0/255.0 blue:181.0/255.0 alpha:0];
self.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; //Zero rect footer to clear empty rows UITableView draws
// [self.window addSubview:self];
}
return self;
}

#pragma mark - Show / Dismiss
- (void)showWithAnimated:(BOOL)animated{
- (void)showInView:(UIView *)superview withEdgeInsets:(UIEdgeInsets)edgeInsets animated:(BOOL)animated {
if (self.animatingState!=Stable) {
return;
}
Expand All @@ -91,17 +83,16 @@ - (void)showWithAnimated:(BOOL)animated{

self.dismissalIndexpath = nil;

[self.window addSubview:self];
self.window.hidden = NO;
[superview addSubViewiew:self withSidesConstrainsInsets:edgeInsets];

if (animated) {
self.animatingState = Showing;
self.window.alpha = 0;
self.alpha = 0;

[self setUserInteractionEnabled:NO];

[UIView animateWithDuration:self.animationDuration animations:^{
self.window.alpha = 1;
self.alpha = 1;
} completion:^(BOOL finished) {
[self show:YES visibleCellsAnimated:YES];
[self setUserInteractionEnabled:YES];
Expand Down Expand Up @@ -240,7 +231,6 @@ - (void)dismissSelf {
BOOL clockwise = self.menuItemsSide == Right ? NO : YES;
[self show:NO cell:self.selectedCell animated:YES direction:direction clockwise:clockwise completion:^(BOOL completed) {
[self removeFromSuperview];
self.window.hidden = YES;
if ([self.yalDelegate respondsToSelector:@selector(contextMenuTableView:didDismissWithIndexPath:)]) {
[self.yalDelegate contextMenuTableView:self didDismissWithIndexPath:[self indexPathForCell:self.selectedCell]];
}
Expand All @@ -258,7 +248,7 @@ - (void)shouldDismissSelf {

- (void)prepareCellForShowAnimation:(UITableViewCell<YALContextMenuCell> *)cell {

// [self resetAnimatedIconForCell:cell];
[self resetAnimatedIconForCell:cell];

Direction direction;
BOOL clockwise;
Expand Down

0 comments on commit 2215ce9

Please sign in to comment.