小编eng*_*f4u的帖子

AVAudio中的remoteControlReceivedWithEvent未被调用

我正在开发一个在后台播放音频的应用程序.我按照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)

请告诉我我还需要什么,或者我在哪里犯任何错误.问候!

iphone avaudioplayer

3
推荐指数
2
解决办法
6294
查看次数

在iPhone sdk4中以编程方式解除/更新本地通知

我正在开发一个在后台运行并将backgroundmode设置为location的应用程序.在didUpdateToLocation:方法中,我想生成本地通知.我希望应用仅在查看以前的通知时显示通知.另一种选择是仅显示最新通知并以编程方式解除所有先前的通知(即,无需用户交互).请指导我怎么可能?

xcode notifications local objective-c ios4

1
推荐指数
1
解决办法
1527
查看次数

标签 统计

avaudioplayer ×1

ios4 ×1

iphone ×1

local ×1

notifications ×1

objective-c ×1

xcode ×1