0

我有两个视图控制器,vc1 和 vc2。我从 vc1 转到 vc2,在 vc2 内我使用网络视图播放 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];
}

请参阅下面白条的截图。

截屏

4

2 回答 2

1

尝试使用根视图控制器初始化导航控制器。

navigationController = [[UINavigationController alloc] initWithRootViewController:vc1];
于 2013-04-16T00:57:22.443 回答
0

我不明白为什么要使用 appDelegate.navigation 控制器,因为您可以使用 rootViewController 启动导航控制器,并根据需要推送和弹出另一个控制器。

但是针对您的情况,我认为大约是frame problem. 在你的goback:sender方法中,在popViewControllerAnimated:调整vc1's frame你想要的方式之后。为此,我认为您应该retain在代码中使用 vc1 控制器。喜欢

    @property (nonatomic, strong) UIViewController *vc1;

在您的标题中,并且

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
           VC1 *vc1 = [[VC1 alloc] init];
           self.vc1 = vc1;

我希望它有帮助:)

于 2013-04-16T02:28:00.423 回答