8
8
9
9
#import " ECSlidingViewController.h"
10
10
11
+ NSString *const ECSlidingViewUnderRightWillAppear = @" ECSlidingViewUnderRightWillAppear" ;
12
+ NSString *const ECSlidingViewUnderLeftWillAppear = @" ECSlidingViewUnderLeftWillAppear" ;
13
+ NSString *const ECSlidingViewTopDidAnchorLeft = @" ECSlidingViewTopDidAnchorLeft" ;
14
+ NSString *const ECSlidingViewTopDidAnchorRight = @" ECSlidingViewTopDidAnchorRight" ;
15
+ NSString *const ECSlidingViewTopDidReset = @" ECSlidingViewTopDidReset" ;
16
+
11
17
@interface ECSlidingViewController ()
12
18
13
19
@property (nonatomic , strong ) UIView *topViewSnapshot;
@@ -35,7 +41,6 @@ - (void)underLeftWillAppear;
35
41
- (void )underRightWillAppear ;
36
42
- (void )topDidReset ;
37
43
- (BOOL )topViewHasFocus ;
38
- - (void )performSelectorOnChildViewControllers : (SEL )selector ;
39
44
40
45
@end
41
46
@@ -222,6 +227,10 @@ - (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplet
222
227
}
223
228
224
229
[self addTopViewSnapshot ];
230
+ dispatch_async (dispatch_get_main_queue (), ^{
231
+ NSString *key = (side == ECLeft) ? ECSlidingViewTopDidAnchorLeft : ECSlidingViewTopDidAnchorRight;
232
+ [[NSNotificationCenter defaultCenter ] postNotificationName: key object: self userInfo: nil ];
233
+ });
225
234
}];
226
235
}
227
236
@@ -247,6 +256,10 @@ - (void)anchorTopViewOffScreenTo:(ECSide)side animations:(void(^)())animations o
247
256
complete ();
248
257
}
249
258
[self addTopViewSnapshot ];
259
+ dispatch_async (dispatch_get_main_queue (), ^{
260
+ NSString *key = (side == ECLeft) ? ECSlidingViewTopDidAnchorLeft : ECSlidingViewTopDidAnchorRight;
261
+ [[NSNotificationCenter defaultCenter ] postNotificationName: key object: self userInfo: nil ];
262
+ });
250
263
}];
251
264
}
252
265
@@ -391,23 +404,29 @@ - (CGFloat)screenWidthForOrientation:(UIInterfaceOrientation)orientation
391
404
392
405
- (void )underLeftWillAppear
393
406
{
394
- [self performSelectorOnChildViewControllers: @selector (underLeftWillAppear )];
407
+ dispatch_async (dispatch_get_main_queue (), ^{
408
+ [[NSNotificationCenter defaultCenter ] postNotificationName: ECSlidingViewUnderLeftWillAppear object: self userInfo: nil ];
409
+ });
395
410
self.underRightView .hidden = YES ;
396
411
[self .underLeftViewController viewWillAppear: NO ];
397
412
self.underLeftView .hidden = NO ;
398
413
}
399
414
400
415
- (void )underRightWillAppear
401
416
{
402
- [self performSelectorOnChildViewControllers: @selector (underRightWillAppear )];
417
+ dispatch_async (dispatch_get_main_queue (), ^{
418
+ [[NSNotificationCenter defaultCenter ] postNotificationName: ECSlidingViewUnderRightWillAppear object: self userInfo: nil ];
419
+ });
403
420
self.underLeftView .hidden = YES ;
404
421
[self .underRightViewController viewWillAppear: NO ];
405
422
self.underRightView .hidden = NO ;
406
423
}
407
424
408
425
- (void )topDidReset
409
426
{
410
- [self performSelectorOnChildViewControllers: @selector (topDidReset )];
427
+ dispatch_async (dispatch_get_main_queue (), ^{
428
+ [[NSNotificationCenter defaultCenter ] postNotificationName: ECSlidingViewTopDidReset object: self userInfo: nil ];
429
+ });
411
430
[self .topView removeGestureRecognizer: self .resetTapGesture];
412
431
[self removeTopViewSnapshot ];
413
432
self.panGesture .enabled = YES ;
@@ -418,14 +437,4 @@ - (BOOL)topViewHasFocus
418
437
return self.topView .center .x == self.resettedCenter ;
419
438
}
420
439
421
- - (void )performSelectorOnChildViewControllers : (SEL )selector
422
- {
423
- NSArray *childViewControllers = [self childViewControllers ];
424
- for (UIViewController *childViewController in childViewControllers) {
425
- if ([childViewController respondsToSelector: selector]) {
426
- [childViewController performSelector: selector];
427
- }
428
- }
429
- }
430
-
431
440
@end
0 commit comments