Commit c5696534 authored by sunzheng's avatar sunzheng
parents d455199f 8ecb4b46
...@@ -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 *rootView = [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) {
...@@ -65,13 +65,13 @@ ImageEditorManger *imageEditorManager = nil; ...@@ -65,13 +65,13 @@ ImageEditorManger *imageEditorManager = nil;
} }
UIEdgeInsets safeInsets = UIEdgeInsetsMake(0, 0, 0, 0); UIEdgeInsets safeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
if (@available(iOS 11.0, *)) { if (@available(iOS 11.0, *)) {
safeInsets = currentWindow.safeAreaInsets; safeInsets = rootView.safeAreaInsets;
NSLog(@" safe insets %.2f, %.2f", safeInsets.top, safeInsets.bottom); NSLog(@" safe insets %.2f, %.2f", safeInsets.top, safeInsets.bottom);
} else { } else {
} }
CGSize size = currentWindow.screen.bounds.size; CGSize size = rootView.bounds.size;
[self.browser showToView:currentWindow containerRect:CGRectMake(safeInsets.left, safeInsets.top, size.width - safeInsets.left - safeInsets.right, size.height - safeInsets.top - safeInsets.bottom)]; [self.browser showToView:rootView containerRect:CGRectMake(safeInsets.left, safeInsets.top, size.width - safeInsets.left - safeInsets.right, size.height - safeInsets.top - safeInsets.bottom)];
} }
#pragma mark - private #pragma mark - private
...@@ -89,7 +89,7 @@ ImageEditorManger *imageEditorManager = nil; ...@@ -89,7 +89,7 @@ ImageEditorManger *imageEditorManager = nil;
[self toEditVC:lfPhotoEditVC]; [self toEditVC:lfPhotoEditVC];
[self.browser.defaultToolViewHandler.sheetView hideWithAnimation:YES]; [self.browser.defaultToolViewHandler.sheetView hideWithAnimation:YES];
} else { } else {
[imgData.yb_auxiliaryViewHandler() yb_showIncorrectToastWithContainer:[Utils currentWindow] text:@"图片未加载完成"]; [imgData.yb_auxiliaryViewHandler() yb_showIncorrectToastWithContainer:[Utils getCurrentVC].view text:@"图片未加载完成"];
} }
} }
......
...@@ -18,7 +18,7 @@ NSString *const LFMediaEditingStrings = @"LFMediaEditingController"; ...@@ -18,7 +18,7 @@ NSString *const LFMediaEditingStrings = @"LFMediaEditingController";
static NSBundle *lfMediaEditingBundle = nil; static NSBundle *lfMediaEditingBundle = nil;
if (lfMediaEditingBundle == nil) { if (lfMediaEditingBundle == nil) {
// 这里不使用mainBundle是为了适配pod 1.x和0.x // 这里不使用mainBundle是为了适配pod 1.x和0.x
lfMediaEditingBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LFBaseEditingController class]] pathForResource:@"LFMediaEditingController" ofType:@"bundle"]]; lfMediaEditingBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LFBaseEditingController class]] pathForResource:@"LFMediaEditingController.bundle/LFMediaEditingController" ofType:@"bundle"]];
} }
return lfMediaEditingBundle; return lfMediaEditingBundle;
} }
......
...@@ -14,8 +14,8 @@ Pod::Spec.new do |s| ...@@ -14,8 +14,8 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/author/RNGeekImageEditor.git", :tag => "master" } s.source = { :git => "https://github.com/author/RNGeekImageEditor.git", :tag => "master" }
s.source_files = "**/*.{h,m}" s.source_files = "**/*.{h,m}"
s.resource_bundles = { s.resource_bundles = {
"YBImageBrowser" => ['YBImageBrowser/**/*.bundle'], "YBImageBrowser" => 'YBImageBrowser/**/*.bundle',
"LFMediaEditingController" => ['LFMediaEditingController/**/*.bundle'] "LFMediaEditingController" => 'LFMediaEditingController/**/*.bundle'
} }
s.resource = "CheckView/**/*.{png, xib}" s.resource = "CheckView/**/*.{png, xib}"
s.requires_arc = true s.requires_arc = true
......
...@@ -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];
} }
......
...@@ -74,7 +74,7 @@ NSBundle *YBIBDefaultBundle(void) { ...@@ -74,7 +74,7 @@ NSBundle *YBIBDefaultBundle(void) {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
NSBundle *_bundle = [NSBundle bundleForClass:NSClassFromString(@"YBImageBrowser")]; NSBundle *_bundle = [NSBundle bundleForClass:NSClassFromString(@"YBImageBrowser")];
NSString *path = [_bundle pathForResource:@"YBImageBrowser" ofType:@"bundle"]; NSString *path = [_bundle pathForResource:@"YBImageBrowser.bundle/YBImageBrowser" ofType:@"bundle"];
bundle = [NSBundle bundleWithPath:path]; bundle = [NSBundle bundleWithPath:path];
}); });
return bundle; return bundle;
......
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