Youtube视频没有在ipad中的uiwebview中显示控制器

时间:2011-09-12 06:02:59

标签: ipad uiwebview youtube

大家好我在ipad和iphone上播放YouTube视频它是通用app.in 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);

    }
}

0 个答案:

没有答案
相关问题