我正在开发一个在后台播放音频的应用程序.我按照app docs的指示编写了iPod控件的代码.我已经实现了这个
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
[self playButtonPressed:playButton];
[self testing];
break;
case UIEventSubtypeRemoteControlPreviousTrack:
[self rewButtonReleased:(UIButton *)rewButton];
break;
case UIEventSubtypeRemoteControlNextTrack:
[self ffwButtonReleased:(UIButton *)ffwButton];
break;
default:
break;
}
}
}
- (BOOL)canBecomeFirstResponder {
NSLog(@"canBecomeFirstResponder");
return YES;
}
Run Code Online (Sandbox Code Playgroud)
和
- (void) viewDidAppear:(BOOL)animated
{
if ([[UIApplication sharedApplication] respondsToSelector:@selector(beginReceivingRemoteControlEvents)]){
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
}
- (void) viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)
请告诉我我还需要什么,或者我在哪里犯任何错误.问候!
我正在开发一个在后台运行并将backgroundmode设置为location的应用程序.在didUpdateToLocation:方法中,我想生成本地通知.我希望应用仅在查看以前的通知时显示通知.另一种选择是仅显示最新通知并以编程方式解除所有先前的通知(即,无需用户交互).请指导我怎么可能?