Skip to content

Commit 2215ce9

Browse files
authored
Revert "change showInSuperView to uiwindow"
1 parent 8af1ecc commit 2215ce9

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

Example/ContextMenu/ViewController.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ - (IBAction)presentMenuButtonTapped:(UIBarButtonItem *)sender {
8888
}
8989

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

9594
#pragma mark - Local methods
@@ -144,4 +143,4 @@ - (UITableViewCell *)tableView:(YALContextMenuTableView *)tableView cellForRowAt
144143
return cell;
145144
}
146145

147-
@end
146+
@end

YALContextMenu/YALContextMenuTableView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ typedef NS_ENUM(NSInteger, MenuItemsAppearanceDirection) {
7171
7272
@param YES or NO weather you want appearance animated or not.
7373
*/
74-
- (void)showWithAnimated:(BOOL)animated;
74+
- (void)showInView:(UIView *)superview withEdgeInsets:(UIEdgeInsets)edgeInsets animated:(BOOL)animated;
7575

7676
/*!
7777
@abstract

YALContextMenu/YALContextMenuTableView.m

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ @interface YALContextMenuTableView ()
3939
@property (nonatomic, strong) UITableViewCell<YALContextMenuCell> *selectedCell;
4040
@property (nonatomic, strong) NSIndexPath *dismissalIndexpath;
4141
@property (nonatomic) AnimatingState animatingState;
42-
@property (nonatomic, strong) UIWindow *window;
4342

4443
@end
4544

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

68-
self.window = [[UIWindow alloc] init];
69-
self.window.windowLevel = UIWindowLevelStatusBar + 1.0f;
70-
self.window.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7f];
71-
self.frame = self.window.frame;
72-
73-
// self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7f];
74-
self.backgroundColor = [UIColor clearColor];
67+
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7f];
7568
self.separatorColor = [UIColor colorWithRed:181.0/255.0 green:181.0/255.0 blue:181.0/255.0 alpha:0];
7669
self.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; //Zero rect footer to clear empty rows UITableView draws
77-
// [self.window addSubview:self];
7870
}
7971
return self;
8072
}
8173

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

9284
self.dismissalIndexpath = nil;
9385

94-
[self.window addSubview:self];
95-
self.window.hidden = NO;
86+
[superview addSubViewiew:self withSidesConstrainsInsets:edgeInsets];
9687

9788
if (animated) {
9889
self.animatingState = Showing;
99-
self.window.alpha = 0;
90+
self.alpha = 0;
10091

10192
[self setUserInteractionEnabled:NO];
10293

10394
[UIView animateWithDuration:self.animationDuration animations:^{
104-
self.window.alpha = 1;
95+
self.alpha = 1;
10596
} completion:^(BOOL finished) {
10697
[self show:YES visibleCellsAnimated:YES];
10798
[self setUserInteractionEnabled:YES];
@@ -240,7 +231,6 @@ - (void)dismissSelf {
240231
BOOL clockwise = self.menuItemsSide == Right ? NO : YES;
241232
[self show:NO cell:self.selectedCell animated:YES direction:direction clockwise:clockwise completion:^(BOOL completed) {
242233
[self removeFromSuperview];
243-
self.window.hidden = YES;
244234
if ([self.yalDelegate respondsToSelector:@selector(contextMenuTableView:didDismissWithIndexPath:)]) {
245235
[self.yalDelegate contextMenuTableView:self didDismissWithIndexPath:[self indexPathForCell:self.selectedCell]];
246236
}
@@ -258,7 +248,7 @@ - (void)shouldDismissSelf {
258248

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

261-
// [self resetAnimatedIconForCell:cell];
251+
[self resetAnimatedIconForCell:cell];
262252

263253
Direction direction;
264254
BOOL clockwise;

0 commit comments

Comments
 (0)