我有兩個視圖控制器,vc1和vc2。從vc1我去vc2,在vc2裏面我使用web視圖播放youtube視頻。當我回到vc1時,屏幕下方出現一個白色條。這是我的代碼。屏幕下方不需要的白條
/* From App Delegate to go vc1 */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
VC1 *vc1 = [[VC1 alloc] init];
navigationController = [[UINavigationController alloc] init];
[navigationController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[navigationController setToolbarHidden:YES];
[navigationController setNavigationBarHidden:YES];
[navigationController setWantsFullScreenLayout:YES];
[navigationController pushViewController:vc1 animated:FALSE];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
/* From VC1 to VC2 */
-(IBAction)gotoVC2:(id)sender
{
VC2 *vc2 = [[VC2 alloc] init];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.navigationController vc2 animated:YES];
}
/* Setting up YouTube View */
-(void) addYouTubeLink:(UIWebView*)webView url:(NSString*)url
{
for (UIView* shadowView in [webView.scrollView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
NSString *videoHTML = [NSString stringWithFormat:@"<html><head></head><body><iframe class=\"youtube-player\" type=\"text/html\" width=\"420\" height=\"315\" src=\"http://www.youtube.com/embed/%@\" align=\"middle\" frameborder=\"1\"></iframe></body></html>",url];
[webView loadHTMLString:videoHTML baseURL:nil];
}
/* Going Back to VC1 */
- (IBAction)goBack:(id)sender {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.navigationController setNavigationBarHidden:YES];
[appDelegate.navigationController setWantsFullScreenLayout:YES];
[appDelegate.navigationController popViewControllerAnimated:YES];
}
請參閱以下白色欄的截圖。
我不知道這有什麼關係你的問題,但你不應該訪問應用程序委託從VC1或VC2獲取導航控制器。你應該使用self.navigationController推.... – rdelmar