我在MPRemoteCommandCenter中获取播放和暂停按钮切换时遇到问题.无论出于何种原因,音频和事件都将正常工作,但命令中心不会将播放按钮更改为暂停按钮.这是我的代码......
- (void)setupMPRemoteCommandCenter{
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
MPRemoteCommand *play = [commandCenter playCommand];
[play setEnabled:YES];
[play addTarget:self action:@selector(playAudio:)];
MPRemoteCommand *pause = [commandCenter pauseCommand];
[pause setEnabled:YES];
[pause addTarget:self action:@selector(playAudio:)];
[commandCenter.skipBackwardCommand setPreferredIntervals:@[@30.0]];
MPRemoteCommand *skipBackwards = [commandCenter skipBackwardCommand];
[skipBackwards setEnabled:YES];
[skipBackwards addTarget:self action:@selector(skipBackwardEvent:)];
[commandCenter.skipForwardCommand setPreferredIntervals:@[@30.0]];
MPRemoteCommand *skipForwards = [commandCenter skipForwardCommand];
[skipForwards setEnabled:YES];
[skipForwards addTarget:self action:@selector(skipForwardEvent:)];
}
-(void)playAudio: (MPRemoteCommandHandlerStatus *)event{
[self playAction];
//playAction handles the audio pausing and toggling the play button on the app
}
Run Code Online (Sandbox Code Playgroud)

让我知道,如果你们能想到任何事情,我会很乐意帮助你.这让我疯了
关于我在这里做错了什么,我感到很困惑.我有一个链接的节点列表(见下面的结构),我很困惑如何在修剪列表时释放内存.我认为将它们添加到数组(eventArr)会使它们以后更容易释放,但我仍然遇到问题!谁能帮助我指出正确的方向?
static void trim_list(int room, int keep, char timestamp[]) {
struct room_t *the_room;
struct room_t *the_room_copy;
struct evnode_t *eventArr[20];
int index = 0;
the_room_copy = malloc(sizeof(struct room_t));
the_room = find_room(room);
the_room_copy->room = the_room->room;
the_room_copy->ecount = the_room->ecount;
the_room_copy->evl_head = the_room->evl_head;
struct evnode_t *node;
int counter;
int removed = 0;
for(counter = 0; counter != keep; counter++){
the_room_copy->evl_head = the_room_copy->evl_head->next;
}
while(the_room_copy->evl_head){
eventArr[index] = the_room_copy->evl_head;
the_room_copy->evl_head = the_room_copy->evl_head->next;
index++;
removed++;
}
for(index = 0; index < removed; index++){
free(eventArr[index]);
} …Run Code Online (Sandbox Code Playgroud)