1

I have a question that apparently is basic. I have an Application that has a Multimedia section with videos in it (Youtube or Ted).

When you select a video (TableView) I open a modal view with a little description and, if it is a Youtube video, a webview where you must click on it to open the video. In the other case I use MPMovieController.

The problem that I have is in Youtube videos. When i close the player, my modal view is closed too and the rest of the application wichs uses modal views doesn't work (it doesn't open the modal views).

Here the code for the description view:

- (void)viewDidLoad{

[super viewDidLoad];

NSRange range = [sendVideo rangeOfString:@"youtube"];


if(range.length>0){


    NSString *htmlString =[NSString stringWithFormat:@"<html><head>"
                           "<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>"
                           "<body style=\"background:#F00;margin-top:0px;margin-left:0px\">"
                           "<div><object width=\"212\" height=\"172\">"
                           "<param name=\"movie\" value=\"%@\"></param>"
                           "<param name=\"wmode\" value=\"transparent\"></param>"
                           "<embed src=\"%@\""
                           "type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"212\" height=\"172\"></embed>"
                           "</object></div></body></html>",sendVideo,sendVideo];



    [youtube loadHTMLString:htmlString baseURL:nil];



}

else

{...

Here is the code I use to select the video in the TableView:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


if(videosContenido ==YES){



    VerDetalles *vd = [[[VerDetalles alloc]initWithNibName:@"VerDetalles"

                                                   bundle:nil]autorelease];



    vd.sendTitle = [aux2 objectAtIndex:[indexPath row]];

    vd.sendDesc = [aux6 objectAtIndex:[indexPath row]];

    vd.sendVideo = [aux4 objectAtIndex:[indexPath row]];

    UINavigationController *navController= [[[UINavigationController alloc]

                                            initWithRootViewController:vd]autorelease];

    if(navController){

        navController.modalPresentationStyle = UIModalPresentationFormSheet;

        navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    }else {

        [tableView deselectRowAtIndexPath:indexPath animated:YES];

    }

    [self presentModalViewController:navController  animated:YES];  

}
  • How you are dismissing the modal view controller?... – iDroid Mar 16 '12 at 10:28
  • I have a button where I call [self.navigationController dismissModalViewControllerAnimated:YES]; With Ted Videos is Ok but with Youtube Videos... it dismiss the modal view but when I try to go to other section with a modal view it doesn't opens. – Enric Montana Mar 16 '12 at 10:38
  • You are creating navigation controller while making the row selection, but you tried to access it like member variable self.navcontroller?.......... – iDroid Mar 16 '12 at 10:41
  • Oh, sorry. That was an error. I solved it but the strange behaviour persists. – Enric Montana Mar 16 '12 at 10:50
  • Have you resetting(replacing the proper objects) the project based on the change you made – iDroid Mar 16 '12 at 10:53
  • Yes, the main problem is that when I close the Youtube video the modal View is closed too (I don't have any idea about the event which is launched on closing the video player). With this code, my button is never called, so automatically dismisses the modal view without making the dismiss modal view. On the other hand, with Ted videos I can make the dismiss modal view because I can use the events of MPMoviePlayerController or the button I implemented. – Enric Montana Mar 16 '12 at 10:57
  • So your web view close action closes your modal view too, right.. This this could be the fault in your code or in your design. Try to recheck everything. If your navcontroller properly released / de allocated then you can create new / retain the instance, and everything will be fine i guess. – iDroid Mar 16 '12 at 11:05
  • I made a trace and I saw that when Youtube closes the modal view doesn't call to dealloc and dismiss. So when I try to access to other modal view, my code creates and makes [self presentModalViewController:navController animated:YES]; with no results. I asume it is because I the application didn't called to dealloc. I tried to retain my navcontroller with no result. By the way, thanks for your help, I hope we can solve it. – Enric Montana Mar 16 '12 at 11:20
  • can you do manual de-allocation, or removal or dismissal – iDroid Mar 16 '12 at 11:27
  • But, where can I do this? In my modal View code? I tried to make this in the view where I have the Table View but when I select a Ted Video and I close that video throught my button, it makes dismiss(and de alloc) correctly, but when I select other video, my code try to remove something that it isn't exists and crashes. – Enric Montana Mar 16 '12 at 11:30
  • Can i have the code for loading and dismissing the you tube. You have to run through the place where you exactly closing your you tube video. – iDroid Mar 16 '12 at 11:35
  • Well, here is the greatest question. My Youtube code is in my question (the UIWebView load, etc.), I don't know how can I manage the close of the video player because is not an object I created, is just a webView where i touch it and it opens the player). – Enric Montana Mar 16 '12 at 11:44
  • so your webview presented modally , and that webview dont have a close button?... – iDroid Mar 16 '12 at 11:47
  • The webview is a part of the modal view. It is represented only by a section which shows the typical preview thumb of Youtube. When you touch this webView, it opens the Player. When I select "Done" on the player it closes the player and the modal view. – Enric Montana Mar 16 '12 at 11:53
  • Show the done button action handler code – iDroid Mar 16 '12 at 12:01
  • ¿How can I make this? I mean, I have no idea about how I can reach the Done Button code of the player. – Enric Montana Mar 16 '12 at 12:05
  • Sorry missed the [link](http://www.iphonedevsdk.com/forum/iphone-sdk-development/61447-how-play-youtube-movie.html) . refer that..Any improvement you 've seen – iDroid Mar 16 '12 at 12:52
  • Hi, take a look at my answer in this thread: [link](http://stackoverflow.com/q/5959367/1082344). – IsaacCisneros Jun 04 '12 at 15:51

1 Answers1

0

I'm having the exact same issue. I noticed that not setting the window.rootViewController property in my app delegate solves the issue. (Just call [window addSubview:rootViewController.view]). However, in iOS 6 the autorotation does not work when the rootViewController of the window is not set.

Werner Altewischer
  • 10,080
  • 4
  • 53
  • 60