我试图仅在页面加载后加载 UIWebView。在页面准备好之前,我只希望显示启动画面。我尝试遵循此页面上的第一个答案(XCode 防止 UIWebView 在 Launch Image 后闪烁白屏),但它似乎不起作用......启动画面加载并且 UIWebView 永远不会加载。
有什么建议吗?
视图控制器.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
IBOutlet UIWebView *webView;
}
@property (nonatomic, retain) IBOutlet UIWebView *webview;
@property(nonatomic, strong) UIImageView *loadingImageView;
@end
视图控制器.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController;
@synthesize webview;
@synthesize loadingImageView;
- (void)viewDidLoad
{
[super viewDidLoad];
//**************** Set website URL for UIWebView
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://http://warm-chamber-7399.herokuapp.com/"] cachePolicy:NSURLCacheStorageAllowed timeoutInterval:20.0]];
//**************** Add Static loading image to prevent white "flash" ****************/
UIImage *loadingImage = [UIImage imageNamed:@"Default.png"];
loadingImageView = [[UIImageView alloc] initWithImage:loadingImage];
loadingImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Default.png"],
nil];
[self.view addSubview:loadingImageView];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
// Remove loading image from view
[loadingImageView removeFromSuperview];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end