Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion LSYReader/LSYReader/Reader/Core/LSYReadUtilites.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
+(void)separateChapter:(NSMutableArray **)chapters content:(NSString *)content;
+(NSString *)encodeWithURL:(NSURL *)url;
+(UIButton *)commonButtonSEL:(SEL)sel target:(id)target;
+(UIViewController *)getCurrentVC;
+(void)showAlertTitle:(NSString *)title content:(NSString *)string;
/**
* ePub格式处理
Expand Down
31 changes: 0 additions & 31 deletions LSYReader/LSYReader/Reader/Core/LSYReadUtilites.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,37 +84,6 @@ +(UIButton *)commonButtonSEL:(SEL)sel target:(id)target
[button addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
return button;
}
+(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)showAlertTitle:(NSString *)title content:(NSString *)string
{
#pragma clang diagnostic push
Expand Down
8 changes: 5 additions & 3 deletions LSYReader/LSYReader/Reader/Model/LSYChapterModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ - (instancetype)init
}
+(id)chapterWithEpub:(NSString *)chapterpath title:(NSString *)title imagePath:(NSString *)path
{
NSString * tmp=[chapterpath URLDecodedString];
LSYChapterModel *model = [[LSYChapterModel alloc] init];
model.title = title;
model.epubImagePath = path;
model.type = ReaderEpub;
model.chapterpath = chapterpath;
NSString* html = [[NSString alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL fileURLWithPath:chapterpath]] encoding:NSUTF8StringEncoding];
model.chapterpath = tmp;
NSString* html = [[NSString alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL fileURLWithPath:tmp]] encoding:NSUTF8StringEncoding];
model.html = html;
model.content = [html stringByConvertingHTMLToPlainText];
[model parserEpubToDictionary];
Expand All @@ -49,7 +50,8 @@ -(void)parserEpubToDictionary
if ([scanner scanString:@"<img>" intoString:NULL]) {
NSString *img;
[scanner scanUpToString:@"</img>" intoString:&img];
NSString *imageString = [self.epubImagePath stringByAppendingPathComponent:img];
NSString *temp = [self.epubImagePath stringByAppendingPathComponent:img];
NSString * imageString=[temp URLDecodedString];
UIImage *image = [UIImage imageWithContentsOfFile:imageString];
CGSize size = CGSizeMake((ScreenSize.width-LeftSpacing-RightSpacing), (ScreenSize.width-LeftSpacing-RightSpacing)/(ScreenSize.height-TopSpacing-BottomSpacing)*image.size.width);
if (size.height>(ScreenSize.height-TopSpacing-BottomSpacing-20)) {
Expand Down
2 changes: 2 additions & 0 deletions LSYReader/LSYReader/Reader/Third/NSString+HTML.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@
// DEPRECIATED - Please use NSString stringByConvertingHTMLToPlainText
- (NSString *)stringByStrippingTags;

-(NSString *)URLEncodedString;
-(NSString *)URLDecodedString;
@end
19 changes: 19 additions & 0 deletions LSYReader/LSYReader/Reader/Third/NSString+HTML.m
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,23 @@ - (NSString *)stringByStrippingTags {

}

- (NSString *)URLEncodedString
{
NSString *encodedString = (NSString *)
CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)self,
(CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]",
NULL,
kCFStringEncodingUTF8));
return encodedString;
}

-(NSString *)URLDecodedString
{
NSString *decodedString=(__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (__bridge CFStringRef)self, CFSTR(""), CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));

return decodedString;
}


@end
21 changes: 20 additions & 1 deletion LSYReader/LSYReader/Reader/View/LSYTopMenuView.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,26 @@ -(void)moreOption
}
-(void)backView
{
[[LSYReadUtilites getCurrentVC] dismissViewControllerAnimated:YES completion:nil];
[[self topViewController] dismissViewControllerAnimated:YES completion:nil];
}
- (UIViewController *)topViewController {
UIViewController *resultVC;
resultVC = [self _topViewController:[[UIApplication sharedApplication].keyWindow rootViewController]];
while (resultVC.presentedViewController) {
resultVC = [self _topViewController:resultVC.presentedViewController];
}
return resultVC;
}

- (UIViewController *)_topViewController:(UIViewController *)vc {
if ([vc isKindOfClass:[UINavigationController class]]) {
return [self _topViewController:[(UINavigationController *)vc topViewController]];
}else if ([vc isKindOfClass:[UITabBarController class]]) {
return [self _topViewController:[(UITabBarController *)vc selectedViewController]];
} else {
return vc;
}
return nil;
}
-(void)layoutSubviews
{
Expand Down