Youtube видео не показывает контроллеры в uiwebview в ipad - PullRequest
1 голос
/ 12 сентября 2011

Привет всем, я играю видео YouTube в ipad и iphone, это универсальное приложение. В iphone он показывает контроллеры, но в ipad он не показывает контроллеры. Код, который я написал, приведен ниже.

-(void)viewWillAppear:(BOOL)animated
{if(self.interfaceOrientation == UIInterfaceOrientationPortrait||self.interfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown)
{

    NSLog(@" before portrait  videowebveiw frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);



    CGRect webviewframe=self.videowebveiw.frame;

    webviewframe.size.width=748.0;
    webviewframe.size.height=1024.0;
    self.videowebveiw.frame=webviewframe;
    embedHTML=[NSString stringWithFormat:@"<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=768.0 height=1024.0></embed></body></html>",self.weburl];

    NSLog(@" after portrait  videowebveiw frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);  

}
else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft||self.interfaceOrientation== UIInterfaceOrientationLandscapeRight)
{


        NSLog(@" before landscape  webview frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);
    CGRect webviewframe=self.videowebveiw.frame;

    webviewframe.size.width=1024.0;
    webviewframe.size.height=748.0;
    self.videowebveiw.frame=webviewframe;

    embedHTML=[NSString stringWithFormat:@"<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=1024.0 height=768.0></embed></body></html>",self.weburl];


        NSLog(@" After landscape  webview frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);

}

    [self loadwebview];



}



-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{


    if(toInterfaceOrientation == UIInterfaceOrientationPortrait||toInterfaceOrientation ==UIInterfaceOrientationPortraitUpsideDown)
    {
        NSLog(@" before portrait  videowebveiw frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);
        CGRect webviewframe=self.videowebveiw.frame;

        webviewframe.size.width=748.0;
        webviewframe.size.height=1024.0;
        self.videowebveiw.frame=webviewframe;




        embedHTML=[NSString stringWithFormat:@"<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=768.0 height=1024.0></embed></body></html>",self.weburl];
        NSLog(@" after portrait  videowebveiw frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);  


    }
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft||toInterfaceOrientation== UIInterfaceOrientationLandscapeRight)
    {
        NSLog(@" before landscape  webview frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);


        CGRect webviewframe=self.videowebveiw.frame;

        webviewframe.size.width=1024.0;
        webviewframe.size.height=748.0;
        self.videowebveiw.frame=webviewframe;

        embedHTML=[NSString stringWithFormat:@"<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=1024.0 height=768.0></embed></body></html>",self.weburl];
        NSLog(@" After landscape  webview frame is %f %f %f %f",self.videowebveiw.frame.origin.x,self.videowebveiw.frame.origin.y,self.videowebveiw.frame.size.width,self.videowebveiw.frame.size.height);

    }
}
...