我注意到UIWebview
今天有一个奇怪的行为。
当您Uiwebview
在模态视图中打开并播放视频时。播放完完整的视频后,我们dismiss
再次uiwebview
调用它,我们就会崩溃。
这里要注意的有趣的一点是,这种行为只存在于iPad
& 在iPhone
.
在调试和启用僵尸时它指出
[MPTransportButton _isChargeEnabled]: message sent to deallocated instance 0x7530930
.
呼叫者,召集者:
#import "POCViewController.h"
#import "POCWebViewController.h"
@interface POCViewController ()
@end
@implementation POCViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)displayWebview:(id)sender {
POCWebViewController *objPOCWebViewController = [[POCWebViewController alloc]init];
[self presentViewController:objPOCWebViewController animated:YES completion:nil];
[objPOCWebViewController release];
}
@end
UIWebview
包含视图控制器
#import "POCWebViewController.h"
@interface POCWebViewController ()
@end
@implementation POCWebViewController
@synthesize webview;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSURL *usl = [NSURL URLWithString:@"Any Youtube url"];
NSURLRequest *urlReq = [NSURLRequest requestWithURL:usl];
[webview loadRequest:urlReq];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
if(webview != nil)
[webview release], webview = nil;
[super dealloc];
}
- (IBAction)dismissTapped:(id)sender {
[self dismissViewControllerAnimated:NO completion:nil];
}
@end
关于我要去哪里错的任何想法?
编辑 1:在玩过代码后,我观察到缺陷仅限于 HTML 中使用的“jw-player”,即 flash 和其他播放器都很好。
您可以尝试使用此链接打开相同的 POC http://www.longtailvideo.com/jw-player/
。这使用了一个 jw 播放器。
播放完整视频时,如果您关闭view controller
包含uiwebview
& 再次呈现它,将导致崩溃。