다음을 통해 공유


iOS의 VisualElement 첫 번째 응답자

이 iOS 플랫폼별을 사용하면 VisualElement 개체가 요소를 포함하는 페이지가 아닌 터치 이벤트에 대한 첫 번째 응답자가 될 수 있습니다. 바인딩 가능한 속성을 true다음으로 설정하여 XAML에서 VisualElement.CanBecomeFirstResponder 사용합니다.

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core">
    <StackLayout>
        <Entry Placeholder="Enter text" />
        <Button ios:VisualElement.CanBecomeFirstResponder="True"
                Text="OK" />
    </StackLayout>
</ContentPage>

또는 흐름 API를 사용하여 C#에서 사용할 수 있습니다.

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...

Entry entry = new Entry { Placeholder = "Enter text" };
Button button = new Button { Text = "OK" };
button.On<iOS>().SetCanBecomeFirstResponder(true);

이 메서드는 VisualElement.On<iOS> 이 플랫폼별이 iOS에서만 실행되도록 지정합니다. VisualElement.SetCanBecomeFirstResponder 네임스페이 Xamarin.Forms.PlatformConfiguration.iOSSpecific 스의 메서드는 터치 이벤트의 첫 번째 응답자가 되도록 설정하는 VisualElement 데 사용됩니다. 또한 이 메서드를 VisualElement.CanBecomeFirstResponder 사용하여 터치 이벤트의 첫 번째 응답자인지 여부를 VisualElement 반환할 수 있습니다.

그 결과 VisualElement 요소가 포함된 페이지가 아닌 터치 이벤트의 첫 번째 응답자가 될 수 있습니다. 이렇게 하면 탭할 때 채팅 애플리케이션이 키보드를 해제하지 않는 등의 시나리오가 Button 가능합니다.