I have two applications in which I use a UIwebView in order to show the mobile youtube page.... I am not sure how to really explain the actual error because this is the first time I am seeing this type of problem... The thing is that it only happens if I try to open that webview multiple times in one session. If I just open it one time it works fine, the second I launch it again it freezes and crashes.... it says Thread1: Program received signal "EXC_BAD_Access".
Here is the code, any help is much appreciated:
Here is the code, any help is much appreciated:
Code:
#import "YoutubeViewController.h"
#import "MainViewController.h"
@implementation YoutubeViewController
@synthesize myWebView;
@synthesize toolbar;
- (void)loadWebPageWithString:(NSString *)urlString
{
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[myWebView loadRequest:request];
}
-(IBAction)back
{
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
-(IBAction)goHome
{
NSString *urlAddress = @"http://m.youtube.com/primedime21";
NSURL *address = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:address];
[myWebView loadRequest:requestObj];
}
-(IBAction)reload
{
NSLog(@"reload");
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewWillDisappear:(BOOL)animated
{
[myWebView stopLoading];
}
- (void)dealloc
{
[myWebView release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.youtube.com/primedime21"]]];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
@end