我连续有两组控件。它们都在各自的堆栈面板中。第一个与左侧对齐,第二个与右侧对齐。它看起来不错,除了右边的控件被应用程序窗口切断。我可以用鼠标拉伸窗口,它看起来很好,但如果按钮只是在应用程序窗口崩溃时按下它会更好。
这是xaml:
<Grid Grid.Row="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
Orientation="Horizontal"
HorizontalAlignment="Left">
<Label Content="Instant Message Text"
Margin="5"></Label>
<TextBox x:Name="txt_Message"
Width="400"></TextBox>
<Button Name="btn_instantMessage"
Content="Send Message"></Button>
<Label Content="Send To All Zones"></Label>
<CheckBox Name="chk_sentMessageToAllZones"
VerticalAlignment="Center"
HorizontalAlignment="Right"></CheckBox>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Left" >
<Button Content="Stop All Ads"
Margin="5"
Name="btn_stop"></Button>
<Button Content="Play All Ads"
Margin="5"
Name="btn_play"></Button>
</StackPanel>
</Grid>
答案 0 :(得分:0)
您应该在窗口/ UC上设置SizeToContent属性。
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.verticalSizeClass != previousTraitCollection?.verticalSizeClass {
tableView.refreshControl = UIRefreshControl() // !!!
tableView.refreshControl.addTarget(self, action: #selector(didPullToRefresh), for: .valueChanged)
}
}
@objc func didPullToRefresh() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
tableView.refreshControl.endRefreshing()
}
// ...
}