【问题标题】:Unable to show tableview from button press on UIView xib无法通过 UIView xib 上的按钮显示 tableview
【发布时间】:2020-03-21 02:52:11
【问题描述】:

在我的应用程序中,用户配置文件包含在 xib 文件中,当用户点击主视图控制器上的按钮时会显示该文件。在 xib 弹出窗口的底部是一个按钮,显示用户在其区域内其他用户的分数的排行榜表视图。我面临的问题是,在 iPhone 8 上,tableview 能够向上滑动并显示,但在 iPhone X 和 iPhone 11 上却没有任何反应。下面我将包含视图层次结构和约束的截图

IBAction里面的代码就是这样执行的

   @IBAction func userTappedScoresIcon(_ sender: Any) {

    //load tableview data
    score_tblView.reloadData()

    scoreViewTopConstraint.constant = 0.0

    UIView.animate(withDuration: 0.25) {
       self.scoresView.frame = self.profile_scroller.bounds

    }

}

我已尝试更改情节提要中的约束以及删除 tableview 顶部的约束,但没有成功。任何帮助将不胜感激!

【问题讨论】:

    标签: ios swift uitableview xib ios-autolayout


    【解决方案1】:

    你可以试试这个例子

    self.topConstraint.constant = -100.0;    
    [self.viewToAnimate setNeedsUpdateConstraints]; 
    [UIView animateWithDuration:1.5 animations:^{
        [self.viewToAnimate layoutIfNeeded]; 
    }];
    
    func AnimateBackgroundHeight() {
       UIView.animateWithDuration(0.5, animations: {
           self.heightCon.constant = 600 // heightCon is the IBOutlet to the constraint
           self.view.layoutIfNeeded()    
       })
    }
    

    【讨论】:

    • 问题被标记为swift
    • 请在设置 heightCon 后在游览动画中添加 self.view.layoutIfNeeded()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 2014-07-28
    • 1970-01-01
    • 2017-11-05
    • 2022-09-22
    • 1970-01-01
    相关资源
    最近更新 更多