我想知道是否有單點觸摸的工作示例,它顯示了一個接收遠程控制事件(例如來自耳機按鈕的事件)的工作示例。單點觸控遠程控制事件不起作用
我已經實現了一個單一的視圖iPhone應用程序,實現了CanBecomeFirstResponder,名爲BecomeFirstResponder和UIApplication.SharedApplication.BeginReceivingRemoteControlEvents()但我沒有得到任何事件。
這是我的SingleViewController的代碼。
public partial class SingleViewViewController : UIViewController
{
public SingleViewViewController() : base ("SingleViewViewController", null)
{
}
public override void DidReceiveMemoryWarning()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
AVAudioSession audioSession = AVAudioSession.SharedInstance();
NSError error;
audioSession.SetCategory(AVAudioSession.CategoryPlayback, out error);
audioSession.SetActive(true,out error);
this.BecomeFirstResponder();
UIApplication.SharedApplication.BeginReceivingRemoteControlEvents();
}
public override void ViewDidUnload()
{
base.ViewDidUnload();
// Clear any references to subviews of the main view in order to
// allow the Garbage Collector to collect them sooner.
//
// e.g. myOutlet.Dispose(); myOutlet = null;
ReleaseDesignerOutlets();
}
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
// Return true for supported orientations
return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
}
public override bool CanBecomeFirstResponder {
get {
return true;
}
}
public override bool CanResignFirstResponder {
get {
return false;
}
}
public override void RemoteControlReceived (UIEvent theEvent)
{
base.RemoteControlReceived (theEvent);
}
}