获取extension,判断第一次
This commit is contained in:
@@ -38,15 +38,53 @@ static BOOL KBIsKeyboardEnabled(void) {
|
||||
ViewController *vc = [[ViewController alloc] init];
|
||||
self.window.rootViewController = vc;
|
||||
|
||||
// Present guide if the custom keyboard is not enabled yet
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self
|
||||
// selector:@selector(applicationDidBecomeActiveNotification:)
|
||||
// name:UIApplicationDidBecomeActiveNotification
|
||||
// object:nil];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!KBIsKeyboardEnabled()) {
|
||||
KBPermissionViewController *guide = [KBPermissionViewController new];
|
||||
guide.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[self.window.rootViewController presentViewController:guide animated:YES completion:nil];
|
||||
}
|
||||
[self kb_presentPermissionIfNeeded];
|
||||
});
|
||||
return YES;
|
||||
}
|
||||
//
|
||||
//#pragma mark - Active notifications
|
||||
//
|
||||
//- (void)applicationDidBecomeActiveNotification:(NSNotification *)note
|
||||
//{
|
||||
// [self kb_presentPermissionIfNeeded];
|
||||
//}
|
||||
|
||||
#pragma mark - Permission presentation
|
||||
|
||||
- (UIViewController *)kb_topMostViewController
|
||||
{
|
||||
UIViewController *root = self.window.rootViewController;
|
||||
if (!root) return nil;
|
||||
UIViewController *top = root;
|
||||
while (top.presentedViewController) {
|
||||
top = top.presentedViewController;
|
||||
}
|
||||
return top;
|
||||
}
|
||||
|
||||
- (void)kb_presentPermissionIfNeeded
|
||||
{
|
||||
BOOL enabled = KBIsKeyboardEnabled();
|
||||
UIViewController *top = [self kb_topMostViewController];
|
||||
if (!top) return;
|
||||
if ([top isKindOfClass:[KBPermissionViewController class]]) {
|
||||
if (enabled) {
|
||||
[top dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!enabled) {
|
||||
KBPermissionViewController *guide = [KBPermissionViewController new];
|
||||
guide.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[top presentViewController:guide animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user