Reputation: 1579
I have two view controllers, vc1 and vc2. From vc1 I go to vc2, inside vc2 I play a youtube video using web view. When I come back to vc1 I get a white bar below my screen. This is my code.
/* 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];
}
Please see the screenshot attached for the white bar below.
Upvotes: 0
Views: 141
Reputation: 1881
I don't get it why you use appDelegate.navigation controller, because you can initiate navigation controller with rootViewController, and push and pop another controller if you want.
But focusing to your situation, I think it's about frame problem
. in your goback:sender
method, after popViewControllerAnimated:
adjust vc1's frame
the way you want. To do this, I think you should retain
vc1 controller in your code. like
@property (nonatomic, strong) UIViewController *vc1;
in your header, and
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
VC1 *vc1 = [[VC1 alloc] init];
self.vc1 = vc1;
I hope it helps :)
Upvotes: 0
Reputation: 12421
Try initializing your navigation controller with a root view controller.
navigationController = [[UINavigationController alloc] initWithRootViewController:vc1];
Upvotes: 1