[英]Xamarin.Forms how to add app rating on Android and iOS?
[英]How can I add a lock screen to my Xamarin.Forms iOS app?
我正在尝试将锁定屏幕添加到我的iOS应用中,以便“ DidEnterBackground”将启用锁定“ OnActivated”。 我见过其他应用使用PIN码执行此操作,只是想知道如何将该功能添加到我的应用中。
我正在使用Xamarin.Forms Xamarin Studio
我怀疑有很多方法可以做到这一点,这是一个建议。
实现一个带有事件的服务IDidDeactivate,在解析器中注册它,并在初始化窗体(App.cs)时挂接到该事件,并根据需要操纵导航,例如Navigation.PushModalAsync(new PinPad())
下面的代码显然是精简的,希望您能理解
// this goes in the Forms project
public interface IDidDeactivate{
event EventHandler Deactivated;
event EventHandler Activated;
}
//this goes in the iOS project
public class WhoDeactivated: IDidDeactivate{
public event EventHandler Deactivated;
public event EventHandler Activated;
public void SendEvent (bool isActivated){
if (isActivated)
Activated(this, new EventArgs());
else
Dectivated(this, new EventArgs());
}
}
// back to the Forms project:
public class SensitivePage: ContentPage{
public SensitivePage(){
var deactivateService = Resolver.Resolve<IDidDeactivate>();
deactivateService.Deactivated += (s,e)=>
Navigation.PushModalAsync(new PinPadPage());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.