【问题标题】:unwind segue changed my UITableView boundsunwind segue 改变了我的 UITableView 界限
【发布时间】:2015-01-19 03:10:38
【问题描述】:

我有一个 unwind segue,但我不知道 unwind segue 会对视图边界做什么。它确实改变了我的 UITableView 界限。有没有办法在 unwind segue 中/之后重新调整我的视图大小?

我发现 unwind segue 不会调用任何视图将/确实出现或加载任何内容。我很困惑为什么我的 UITableView 边界发生了变化。

我使用情节提要创建了所有视图和控制器。我有一个侧边栏和主视图,在侧边栏上,有一个设置按钮可以加载与侧边栏视图大小完全相同的设置视图。

当主视图 -> 滑出侧边栏时,我手动计算了表格视图边界,以显示所有单元格:

-(void) viewDidAppear {
[super viewDidAppear];
[self.ProjectTableView setFrame:CGRectMake(self.view.bounds.origin.x,
                                               self.SideBarHeaderBGImageView.bounds.size.height + self.HomeButton.bounds.size.height + self.AlertButton.bounds.size.height,
                                               self.view.bounds.size.width,
                                               self.view.bounds.size.height - self.SideBarHeaderBGImageView.bounds.size.height - self.HomeButton.bounds.size.height - self.AlertButton.bounds.size.height)];
}

我对设置视图使用展开转场以返回侧边栏视图:

- (IBAction)unwindToSideBar:(UIStoryboardSegue *)unwindSegue
{
    // get the unwind view controllers
#ifdef DEBUG
    NSLog(@"%@ triggered unwind segue to SideBar", unwindSegue.sourceViewController);
#endif
    if ([unwindSegue.sourceViewController isKindOfClass:[UserSettingViewController class]]) {
        __block UIViewController *UserSettingVC = unwindSegue.sourceViewController;
        //setup animateFrame
        CGRect animateFrame = CGRectMake(-UserSettingVC.view.frame.size.width,
                                         0,
                                         UserSettingVC.view.frame.size.width,
                                         UserSettingVC.view.frame.size.height);
        [UIView animateWithDuration:0.3
                              delay:0
                            options:UIViewAnimationOptionCurveEaseInOut
                         animations:^{
                             UserSettingVC.view.frame = animateFrame;
                             UserSettingVC.view.alpha = 0.0f;
                         }
                         completion:^(BOOL finished) {
                             UserSettingVC.view.alpha = 0.0f;
                             [UserSettingVC willMoveToParentViewController:nil];
                             [UserSettingVC.view removeFromSuperview];
                             [UserSettingVC removeFromParentViewController];
                             UserSettingVC = nil;
                             //[self resizeSubViews];
                             //NSLog(@"self view height %f, bg %f, home %f, alert %f, proj y %f", self.view.bounds.size.height, self.SideBarHeaderBGImageView.bounds.size.height, self.HomeButton.bounds.size.height, self.AlertButton.bounds.size.height, self.SideBarHeaderBGImageView.bounds.size.height + self.HomeButton.bounds.size.height + self.AlertButton.bounds.size.height);

                             //NSLog(@"proj height %f", self.view.bounds.size.height - self.SideBarHeaderBGImageView.bounds.size.height - self.HomeButton.bounds.size.height - self.AlertButton.bounds.size.height);
                         }];
    }
}

我尝试在完成块中再次设置 ProjectTableView 框架,虽然它打印正确的值,但实际大小不正确。 我试图打印 UITable 视图边界,看起来很正常,但我的底部单元格无法显示。如果我拉开窗户,你可以看到它们,但是当我松开手指时,它会进入屏幕下方。

我怀疑 unwind segue 重置了我的 UITable 视图大小,但我不知道在哪里重新计算它们。 unwind segue 不会调用 ViewDidAppear。

【问题讨论】:

    标签: ios objective-c uitableview


    【解决方案1】:

    我想通了,它是关于自动布局的。禁用或添加足够的布局将起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多