1

如果我将某些内容推送到导航控制器然后弹回主页,主页中的滚动视图将停止工作。如果我重新打开应用程序而不向导航控制器推送任何内容,它可以正常工作。滚动视图是延伸到框架之外的水平滚动视图。我用它来滚动按钮,比如在 iOS 中切换应用程序(iOS 多任务)。

这是我推送新 vc 的代码

    UIViewController *newVC = [[UIViewController alloc] init];    
    UILabel *label = [[UILabel alloc] initWithFrame:self.view.bounds];
    [label setTextAlignment:NSTextAlignmentCenter];
    label.text = [NSString stringWithFormat:@"promo %i detail view",[sender tag]];
    label.backgroundColor = [UIColor whiteColor];
    [newVC.view addSubview:label];

    [self.navigationController setNavigationBarHidden:NO animated:NO];
    [self.navigationController pushViewController:newVC animated:YES];

当该视图控制器被弹出并且导航控制器移回主页时,我隐藏了导航栏。

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
        if(viewController == self){
            [self.navigationController setNavigationBarHidden:YES];
            NSLog(@"%d", [self.scrollMenuBar isScrollEnabled]);
        }
    }

检查 isScrollEnable 返回 true。

我尝试推送一个正常的模态视图,并出现同样的问题。

4

3 回答 3

1

如果您在 viewDidLayoutSubview 函数中调整滚动视图内容的大小,它将再次起作用。

- (void) viewDidLayoutSubviews {
    [self resizeScrollViewContent];
}
于 2013-09-24T17:10:34.280 回答
0

Problem solved by creating the UIScrollview and the button inside it programmatically. Not sure what I did wrong with storyboard, but it's a pain.

于 2013-05-15T12:21:18.370 回答
0

[self.scrollbarMenu setScrollEnabled:YES];在主页面的 viewdidAppear 中添加

添加

[scroll setContentSize:CGSizeMake(width , height)];

仍然如果它不起作用 2 种可能性

  1. 内存无效。
  2. 其他一些视图位于滚动视图上方
于 2013-05-14T09:12:55.273 回答