所以我一直在干预将一个小型 SwiftUI iPad 应用程序“移动”到 Mac,并且我在使用UIDocumentPickerViewController. 我已经包裹UIDocumentPickerViewController在一个UIViewControllerRepresentable像这样:
struct DocumentPickerView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
let documentPicker = UIDocumentPickerViewController(documentTypes: [(kUTTypeImage as String)], in: .import)
return documentPicker
}
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {
}
}
Run Code Online (Sandbox Code Playgroud)
并像这样显示它:
struct ContentView: View {
@State var shows = false
var body: some View {
Button(action: { self.shows.toggle() }) {
Text("Select File")
}
.sheet(isPresented: self.$shows) {
DocumentPickerView()
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是当在 Mac 上时,UIDocumentPickerViewController …
我今天要面对的是滚动查看器,事实上它会阻止我的事件。SO..这里有一些 xaml:
<ScrollViewer x:Name="scrollv" Panel.ZIndex="15" Margin="8,65.5,0,22" VerticalScrollBarVisibility="Visible" Height="392.5" Background="White" IsHitTestVisible="False">
<Grid x:Name="listaintrebari" Height="Auto" Width="301.5" HorizontalAlignment="Left" VerticalAlignment="Top" Background="White" >
</Grid>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
所以事情是:在滚动查看器内部的网格上,我以编程方式添加问题 UserControl...其中顺便有一个带有单击事件的按钮。我的问题是我无法单击该按钮...就像滚动查看器一样就像一个隐形的盾牌一样,保护用户控件和按钮免受邪恶鼠标的侵害!
任何帮助表示赞赏!
编辑:(这是我的问题用户控制)
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:eHelper_v3"
mc:Ignorable="d"
x:Class="eHelper_v3.questions"
x:Name="IntrebareControl" Width="330.641" Margin="0" MouseLeftButtonDown="IntrebareControl_MouseLeftButtonDown"
>
<Grid x:Name="LayoutRoot" ScrollViewer.VerticalScrollBarVisibility="Disabled" Margin="0,0,13,0" Height="90" >
<Rectangle x:Name="rect" Panel.ZIndex="20" Height="90" Stroke="#FF0975A3" >
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#1404BFD8" Offset="0.004"/>
<GradientStop Color="#1300A7FF" Offset="0.996"/>
<GradientStop Color="#2B0F82CC" Offset="0.459"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Image x:Name="imagine" HorizontalAlignment="Left" Margin="8,8,0,8" Width="126.667" Stretch="Fill" MouseLeftButtonDown="imagine_MouseLeftButtonDown" />
<TextBlock x:Name="textul" Margin="138.667,8,8,22.5" TextWrapping="Wrap" Text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" FontSize="9.333"/>
<Label …Run Code Online (Sandbox Code Playgroud) c# ×1
ios ×1
mac-catalyst ×1
macos ×1
routedevents ×1
scrollviewer ×1
swift ×1
swiftui ×1
wpf ×1