Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 更新静态表视图的滚动_Ios_Swift_Uitableview_Uiscrollview - Fatal编程技术网

Ios 更新静态表视图的滚动

Ios 更新静态表视图的滚动,ios,swift,uitableview,uiscrollview,Ios,Swift,Uitableview,Uiscrollview,我正在尝试获取uitableview的滚动视图,该视图是静态的,可以更新。我有一个容器视图,可以更改大小,并且可以工作,但是我无法获取要更新的滚动区域 我试过setNeedsDisplay和setNeedsLayout,但没有成功 有什么想法吗 class TimeAwayRequestTableViewController: UITableViewController { var originalHeight : CGFloat! @IBOutlet var selectedDate :

我正在尝试获取uitableview的滚动视图,该视图是静态的,可以更新。我有一个容器视图,可以更改大小,并且可以工作,但是我无法获取要更新的滚动区域

我试过setNeedsDisplay和setNeedsLayout,但没有成功

有什么想法吗

class TimeAwayRequestTableViewController: UITableViewController {

var originalHeight : CGFloat!

@IBOutlet var selectedDate : UIView!

@IBOutlet var calendarView: CalendarView!

override func viewDidLoad() {
    super.viewDidLoad()

    originalHeight = self.tableView.contentSize.height

    calendarView.delegate = self

    self.selectedDate.frame.size.height = CGFloat(SelectedDatesTimeAway.selectedDates.count * 44)
}

override func preferredContentSizeDidChangeForChildContentContainer(container: UIContentContainer) {
    self.selectedDate.frame.size.height = CGFloat(SelectedDatesTimeAway.selectedDates.count * 44)
    self.tableView.contentSize.height = self.originalHeight + self.selectedDate.frame.size.height
    self.tableView.setNeedsDisplay()
    self.tableView.setNeedsLayout()
}

}

extension TimeAwayRequestTableViewController : CalendarViewDelegate {

func calendarDidSelectDate(date: Moment) {
    let theDate = date.date
    SelectedDatesTimeAway.selectedDates.append(theDate)
    print(SelectedDatesTimeAway.selectedDates.count)
    let tbc = self.childViewControllers[0] as! UITableViewController
    tbc.preferredContentSize.height = CGFloat ( SelectedDatesTimeAway.selectedDates.count * 44 )
    print(tbc.preferredContentSize.height)
    tbc.tableView.reloadData()
}

func calendarDidPageToDate(date: Moment) {
    print(date)
}

}

如果我了解问题的性质,您需要在更改内容时更新
UIScrollView
contentSize
属性。

如果我了解您问题的性质,您需要在更改内容时更新
UIScrollView
contentSize
属性