Opening youTube in iOS not work -


i'm trying create youtube app in app

mt source code load webview is:

viewcontroller header file:

@interface viewcontroller : uiviewcontroller  @property (nonatomic, strong) uiwebview *webview;  @end 

viewcontroller implementation file - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib.

self.webview = [[uiwebview alloc] initwithframe:cgrectmake(0, 0, 300, 200)]; self.webview.layer.borderwidth = 1.0; self.webview.layer.bordercolor = [uicolor redcolor].cgcolor;  self.webview.backgroundcolor = [uicolor blackcolor];  self.webview.center = self.view.center;  [self.view addsubview:self.webview];  nsstring* embedhtml = @"\ <html><head>\ <style type=\"text/css\">\ body {\     background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>";  nsurl *url = [nsurl urlwithstring:@"https://www.youtube.com/watch?v=k14rntvt194"];  nsstring* html = [nsstring stringwithformat:embedhtml, url, self.webview.frame.size.width, self.webview.frame.size.height];  [self.webview loadhtmlstring:html baseurl:nil]; 

}

when run, app crashes , gives me following screen

enter image description here

how solve issue?

your code working fine, therefore problem not because of webview. can see "thread 1" on left panel , last process before crash on thread says "__psynch_mutexwait". may error in couple of situations that;

  1. wrong set nstimer
  2. wrong set or unmanageable nsnotification (especially key-value-observer)
  3. one of objects tries access coredata objects on background thread while using main-threads context or using same managed object context on different threads (background or main) @ same time.

try check if doing wrong 1 of scenarios. also, try async operation try;

dispatch_async(dispatch_get_current_queue(), ^{     // work needs done on main thread }); 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -