2017-12-02 5 views
1

내 코코스 샤프 게임에서 뒤로 버튼 이벤트를 잡는 적절한 방법은 무엇입니까? Android 프로젝트에서 발생해야합니까, 아니면 PCL 핵심에서 수행 할 수 있습니까?Android 기기의 뒤로 버튼을 추적하는 방법은 무엇입니까?

어떻게 끝나나요?

+1

난 당신이 안드로이드 프로젝트에서 그것을 할 필요가 있다고 생각합니다. 주 활동을 만들 때 AppDelegate에 처리기를 만들어야합니다. 여기에 [발견 된 링크] (https://forums.xamarin.com/discussion/44838/need-a-good-example-of-handling- back-button-press) 도움이 될만한가? –

+0

PCL에서 [onBackButtonPressed()] (https://developer.xamarin.com/api/member/Xamarin.Forms.NavigationPage.OnBackButtonPressed() /) 메소드를 구현할 수 있다고 생각합니다. 이 작업은 PCL ContentPage의 XAML 코드에서 수행 할 수 있습니다. – ADimaano

+0

아니요,하지만 더 이상이 솔루션을 찾지 않습니다. CocosSharp는 죽은 상어입니다. 어쨌든 고마워. – modiX

답변

1

@ADimaano가 말했듯이 OnBackButtonPressed 메서드를 재정 의하여 PCL에 적용 할 수 있습니다. 예를 들어

:

public partial class MainPage : ContentPage 
{ 
    public MainPage() 
    { 
     InitializeComponent(); 
    } 

    protected override bool OnBackButtonPressed() 
    { 
     //Do something 
     return base.OnBackButtonPressed(); 
    } 
} 
+0

이 솔루션은 간단한 Xamarin 앱을위한 것이지만 Xamarin 팀이 만든 엔진 CocosSharp에 대해 이야기하고 있으며 장면 역학의 뒤에서 비슷한 것을 사용합니다. CocosSharp가 가지고 있지 않은 한 가지는 페이지입니다. – modiX