fix LeaWebViewController crash & share options crash & pick image crash

This commit is contained in:
lealife
2020-04-25 12:19:22 +08:00
parent 4a5b6b1191
commit 3f27cef853
5 changed files with 22 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -24,6 +24,7 @@
#import "UIImage+Util.h" #import "UIImage+Util.h"
#import "WPFontManager.h" #import "WPFontManager.h"
#import "WPStyleGuide.h" #import "WPStyleGuide.h"
#import <WPMediaPicker/WPMediaPicker.h> #import <WPMediaPicker/WPMediaPicker.h>
#import <QBImagePickerController/QBImagePickerController.h> #import <QBImagePickerController/QBImagePickerController.h>
@@ -447,8 +448,8 @@ BOOL hiddenBar = NO;
- (void)editorDidPressMedia:(WPEditorViewController *)editorController - (void)editorDidPressMedia:(WPEditorViewController *)editorController
{ {
// [self showPhotoPickerForBetterDevice]; [self showPhotoPickerForBetterDevice];
// return; return;
// iphone // iphone
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Add Photo", nil) message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Photo Library", nil),NSLocalizedString(@"Take Photo", nil), nil]; UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Add Photo", nil) message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Photo Library", nil),NSLocalizedString(@"Take Photo", nil), nil];
@@ -702,7 +703,7 @@ BOOL hiddenBar = NO;
QBImagePickerController *imagePickerController = [QBImagePickerController new]; QBImagePickerController *imagePickerController = [QBImagePickerController new];
imagePickerController.delegate = self; imagePickerController.delegate = self;
imagePickerController.allowsMultipleSelection = YES; imagePickerController.allowsMultipleSelection = YES;
imagePickerController.maximumNumberOfSelection = 6; imagePickerController.maximumNumberOfSelection = 1;
imagePickerController.showsNumberOfSelectedAssets = YES; imagePickerController.showsNumberOfSelectedAssets = YES;
imagePickerController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; imagePickerController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:imagePickerController animated:YES completion:NULL]; [self presentViewController:imagePickerController animated:YES completion:NULL];
@@ -806,15 +807,20 @@ BOOL hiddenBar = NO;
} }
- (void)addMediaAssets:(NSArray *)assets - (void)addMediaAssets:(NSArray *)assets
{ {
NSString *urls = @"["; NSMutableArray * array = [[ NSMutableArray alloc]init];
// NSString *urls = @"[";
for (ALAsset *asset in assets) { for (ALAsset *asset in assets) {
NSString *fileId = [self addImageAssetToContent:asset]; NSString *fileId = [self addImageAssetToContent:asset];
urls = [NSString stringWithFormat:@"%@'%@',", urls, [self getImageUrl:fileId]]; // urls = [NSString stringWithFormat:@"%@'%@',", urls, [self getImageUrl:fileId]];
[array addObject:[self getImageUrl:fileId]];
} }
urls = [NSString stringWithFormat:@"%@]", urls]; // urls = [NSString stringWithFormat:@"%@]", urls];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self.editorView insertImage:urls alt:@""]; // [self.editorView insertImage:urls alt:@""];
for (NSString *object in array) {
[self.editorView insertImage:object alt:@""];
}
}); });
} }

View File

@@ -4,7 +4,7 @@
@interface LeaWebViewController : UIViewController<WKNavigationDelegate> @interface LeaWebViewController : UIViewController<WKNavigationDelegate>
// Interface // Interface
@property (nonatomic, weak) IBOutlet WKWebView *webView; @property (nonatomic, strong) IBOutlet WKWebView *webView;
//@property (nonatomic, weak) IBOutlet WKWebView *wkView; //@property (nonatomic, weak) IBOutlet WKWebView *wkView;
@property (nonatomic, strong) IBOutlet UIToolbar *toolbar; @property (nonatomic, strong) IBOutlet UIToolbar *toolbar;
@property (nonatomic, strong) IBOutlet UIView *loadingView; @property (nonatomic, strong) IBOutlet UIView *loadingView;

View File

@@ -373,6 +373,7 @@
return (content || '').trim().substr(0, 50);\ return (content || '').trim().substr(0, 50);\
})();\ })();\
"; ";
// js = @"document.body.outerHTML";
//JS //JS
[self.webView evaluateJavaScript:js completionHandler:^(id _Nullable result, NSError * _Nullable error) { [self.webView evaluateJavaScript:js completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSLog(@"get desc ret %@ %@", error, result); NSLog(@"get desc ret %@ %@", error, result);
@@ -599,17 +600,18 @@
NSString* permaLink = [self getDocumentPermalink]; NSString* permaLink = [self getDocumentPermalink];
NSString *title = [self getDocumentTitle]; NSString *title = [self getDocumentTitle];
dispatch_async(dispatch_get_main_queue(), ^{
[self getDocumentDesc:^(NSString *desc){ [self getDocumentDesc:^(NSString *desc){
NSLog(@"showLinkOptions desc: %@", desc); NSLog(@"showLinkOptions link: %@, title: %@, desc: %@", permaLink, title, desc);
NSMutableArray *activityItems = [NSMutableArray array]; NSMutableArray *activityItems = [NSMutableArray array];
if (title) { if (title) {
[activityItems addObject:title]; [activityItems addObject:title];
} }
if (desc) { // if (desc) {
[activityItems addObject:desc]; // [activityItems addObject:desc];
} // }
// weixin // weixin
NSArray *activities = @[[[WeixinSessionActivity alloc] init], [[WeixinTimelineActivity alloc] init]]; NSArray *activities = @[[[WeixinSessionActivity alloc] init], [[WeixinTimelineActivity alloc] init]];
@@ -624,7 +626,7 @@
if (!completed) { if (!completed) {
return; return;
} }
// [WPActivityDefaults trackActivityType:activityType]; // [WPActivityDefaults trackActivityType:activityType];
}; };
if (IS_IPAD) { if (IS_IPAD) {
@@ -639,6 +641,7 @@
[self presentViewController:activityViewController animated:YES completion:nil]; [self presentViewController:activityViewController animated:YES completion:nil];
} }
}]; }];
});
} }
- (void)reload - (void)reload