Commit affefcd0 authored by huanglu's avatar huanglu

update

parent f5ef3a6f
...@@ -53,7 +53,7 @@ ImageEditorManger *imageEditorManager = nil; ...@@ -53,7 +53,7 @@ ImageEditorManger *imageEditorManager = nil;
data.imageURL = [NSURL URLWithString:image.origImage]; data.imageURL = [NSURL URLWithString:image.origImage];
[dataSource addObject:data]; [dataSource addObject:data];
} }
UIWindow *currentWindow = [Utils currentWindow]; UIView *currentWindow = [Utils getCurrentVC].view;
self.browser.dataSourceArray = dataSource; self.browser.dataSourceArray = dataSource;
self.browser.currentPage = model.index; self.browser.currentPage = model.index;
if (model.editable) { if (model.editable) {
......
...@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSData *)imageData:(UIImage *)image; + (NSData *)imageData:(UIImage *)image;
+ (UIWindow *) currentWindow; + (UIViewController *)getCurrentVC;
+ (void) toVC:(UIViewController *)vc; + (void) toVC:(UIViewController *)vc;
......
...@@ -73,13 +73,36 @@ ...@@ -73,13 +73,36 @@
return data; return data;
} }
+ (UIWindow *) currentWindow { //获取当前屏幕显示的viewcontroller
return [UIApplication sharedApplication].keyWindow; + (UIViewController *)getCurrentVC {
UIViewController *result = nil;
UIWindow * window = [[UIApplication sharedApplication] keyWindow];
if (window.windowLevel != UIWindowLevelNormal)
{
NSArray *windows = [[UIApplication sharedApplication] windows];
for(UIWindow * tmpWin in windows)
{
if (tmpWin.windowLevel == UIWindowLevelNormal)
{
window = tmpWin;
break;
}
}
}
UIView *frontView = [[window subviews] objectAtIndex:0];
id nextResponder = [frontView nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]])
result = nextResponder;
else
result = window.rootViewController;
return result;
} }
+ (void) toVC:(UIViewController *)vc { + (void) toVC:(UIViewController *)vc {
UIWindow *window = [Utils currentWindow]; UIViewController *rootVC = [Utils getCurrentVC];
UIViewController *rootVC = window.rootViewController;
vc.modalPresentationStyle = UIModalPresentationCustom; vc.modalPresentationStyle = UIModalPresentationCustom;
[rootVC presentViewController:vc animated:true completion:nil]; [rootVC presentViewController:vc animated:true completion:nil];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment