У меня есть приложение для iphone, опубликованное и работающее в течение 1 года. Я решил восстановить как родную версию iPhone / iPad. Он использует вкладки, а одна вкладка содержит список видео компании youTube, которые при выборе могут быть сделаны для воспроизведения в полноэкранном режиме в альбомном режиме. Хотя это прекрасно работает в версии для iPhone (тот же код) на iPad отличается - играет изначально в крошечном окне, которое можно развернуть, но не будет воспроизводить в альбомном режиме. Обратите внимание, что youTubeIdentifier передает идентификатор видео. Выдернул мои волосы и искал высоко и низко, но не могу понять, почему на iPad все по-другому. Основной код ниже, любые советы очень ценятся. ... Кит
UIWebView * webView;
- (void) initUIWebView
{
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 360, 320)];//init and create the UIWebView
webView.delegate = self;
webView.autoresizesSubviews = YES;
webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth);
}
- (void) viewDidLoad {
[super viewDidLoad];
connectionWasChecked = NO;
[self initUIWebView];
[[self view] addSubview:webView];
lastConnectionType = iNetStat; // save current type
[self showVideo];
return;
}
-(void) showVideo
{
if(iNetStat == 1) // Only allow on WiFi cnnection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
htmlString = [NSString stringWithFormat:@"<object ><param name=\"movie\" "
"value=\"http://www.youtube.com/watch?feature=player_detailpage&%@\"><param name=\"allowFullScreen\" "
"value=\"true\"><param name=\"allowScriptAccess\" value=\"always\"><embed "
"src=\"http://www.youtube.com/watch?feature=player_detailpage&%@\"type=\"application/x-shockwave-flash\" "
"allowfullscreen=\"true\" allowScriptAccess=\"always\"></object>", youTubeIdentifier, youTubeIdentifier];
strURL = [NSString stringWithFormat:@"http://www.youtube.com/watch?feature=player_detailpage&%@", youTubeIdentifier];
[webView setHidden:NO];
[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString: strURL]];
}
else if(!connectionWasChecked)
{
[webView setHidden:YES];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Warning - No WiFi available!" message:@"You need a WiFi connection to view this video."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[alert show];
connectionWasChecked = YES;
return;
}
lastConnectionType = iNetStat; // save current type
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}