ios - reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath -


i've 1 tableview different section , each section have 1 row. if section selected video playing in mpmovieplayerviewcontroller. after click on done button app crashing times(some sections particular only).

my code below:

subcategorytable=[[uitableview alloc]initwithframe:cgrectmake(0,0,375,667) style:(uitableviewstyleplain)]; subcategorytable.datasource=self; subcategorytable.delegate=self; subcategorytable.separatorcolor=[uicolor orangecolour]; subcategorytable.hidden=yes; subcategorytable.backgroundview=nil; [subcategorytable registerclass:[uitableviewcell class] forcellreuseidentifier:@"subcatcellid"]; [self.view addsubview:subcategorytable];       ***cellforrowatindexpath***      static nsstring *cellidentifier3 = @"subcatcellid";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier3                              ];      if (cell == nil)     {         cell = [[uitableviewcell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier3];     }      cell.textlabel.text=[productarray objectatindex:indexpath.section];     uifont * font=[uifont fontwithname:@"trebuchetms-bold" size:18];     cell.textlabel.font=font;     cell.textlabel.textcolor=[uicolor whitecolor];     cell.backgroundcolor=[uicolor orangecolor];      cell.selectionstyle=uitableviewcellselectionstylenone;     return cell;    ***didselectrowatindexpath***      nsstring *strurl=[nsstring stringwithformat:@"%@",[producturl objectatindex:indexpath.section]];      strurl=[strurl stringbyreplacingoccurrencesofstring:@" " withstring:@"%20"];     nsurl * imageurl = [nsurl urlwithstring:strurl];     nsdictionary *videos = [hcyoutubeparser h264videoswithyoutubeurl:imageurl];     if (!movieplayer)         movieplayer = [[mpmovieplayerviewcontroller alloc] initwithcontenturl:[nsurl urlwithstring:[videos objectforkey:@"medium"]]];      [movieplayer.movieplayer setcontrolstyle: mpmoviecontrolstylefullscreen];     [movieplayer.movieplayer setfullscreen:yes animated:yes];     [self presentmovieplayerviewcontrolleranimated:movieplayer];      [[nsnotificationcenter defaultcenter] addobserver:self                                              selector:@selector(movieplaybackdidfinish:)                                                  name:mpmovieplayerplaybackdidfinishnotification                                                object:movieplayer.movieplayer];            ***movieplaybackdidfinish***  [movieplayer removefromparentviewcontroller]; movieplayer =  nil; subcategorytable.hidden=no; [subcategorytable reloaddata]; 

i've checked few other questions still can't figure out why happening.

please tell one....

you can try using dismissmovieplayerviewcontrolleranimated method instead of using removefromparentviewcontroller in movieplaybackdidfinish.

-(void)movieplaybackdidfinish:(nsnotification*)anotification{     int value = [[anotification.userinfo valueforkey:mpmovieplayerplaybackdidfinishreasonuserinfokey] intvalue];     if (value == mpmoviefinishreasonuserexited) {         [self dismissmovieplayerviewcontrolleranimated];     }     subcategorytable.hidden=no;     [subcategorytable reloaddata]; } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -