uiwebview가있는 응용 프로그램을 개발 중이며 해당 webview에서 uiwebview가 Java를 통해 원시 메소드를 호출 할 때 로컬 pdf 파일을로드해야합니다. 그리고 내가 성공적으로 일을하지만 내가 webisete 활동 표시기를 통해 탐색 할 때 잘 표시하지만 네이티브 함수 호출 및 uiwebview에서 PDF로드 할 때 그것은 URL에서 PDF로드하는 동안 doesnot 보여줍니다. 내 코드를 여기에 게시하도록하겠습니다. UIWebViewDelegate 방법에활동 표시기가 PDF에 표시되지 않습니다. uiwebview로드
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize webPage;
- (BOOL) shouldAutorotate{
return NO;
}
- (void)viewDidLoad
{
[super viewDidLoad];
webLink = @"http://url.com/m/";
liNk = webLink;
[webPage loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:liNk]]];
webPage.backgroundColor = [UIColor blackColor];
//[[webPage.subviews objectAtIndex:0] setBounces:NO];
[(UIScrollView*)[webPage.subviews objectAtIndex:0] setShowsVerticalScrollIndicator:NO];
[webPage addSubview:activity];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES];
webPage.delegate = self;
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
if ([[[request URL] absoluteString] hasPrefix:@"ios:"]) {
// Call the given selector
[self performSelector:@selector(webToNativeCall)];
return NO;
}
return YES;
}
- (void)webToNativeCall
{
NSString *pdfurl = @"http://url.com/mypdf.pdf";
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:pdfurl]];
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent]stringByAppendingPathComponent:@"Documents"]];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"mypdf.pdf"];
[pdfData writeToFile:filePath atomically:YES];
// Now create Request for the file that was saved in your documents folder
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webPage setUserInteractionEnabled:YES];
[webPage setDelegate:self];
[webPage loadRequest:requestObj];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
나는 코드의 complele 흐름을하지 않았다. 하지만 UIActivityIndicatorView를 사용하는 경우 [activity startAnimating]을 시도하십시오. 활동 표시기와 [activity stopAnimating]을 표시합니다. 중지하려면 – Dili
답장을 보내 주셔서 감사합니다. 나는 그랬지만 여전히 활동 표시를 보이지 않았다. 나는 심지어 정상적으로 작동하지 않는 사용자 상태 표시 줄 기본 표시기를 시도했다. – user2966615