我正在使用AVQueuePlayer/AVFoundation在iOS应用程序中播放音频文件.我已经设置了MPNowPlayingInfoCenter现在播放的信息,如专辑标题,艺术家,艺术品,像这样
NSMutableDictionary *albumInfo = [[NSMutableDictionary alloc] init];
MPMediaItemArtwork *artworkP;
UIImage *artWork = [UIImage imageNamed:album.imageUrl];
[albumInfo setObject:album.title forKey:MPMediaItemPropertyTitle];
[albumInfo setObject:album.auther forKey:MPMediaItemPropertyArtist];
[albumInfo setObject:album.title forKey:MPMediaItemPropertyAlbumTitle];
[albumInfo setObject:artworkP forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:albumInfo]
并且还可以访问应用程序委托中的远程事件,以便从锁定屏幕播放,暂停,下一个,上一个事件.但搜索栏无法访问,即使我没有找到任何设置搜索属性的选项.
我想设置搜索属性,并希望在我的应用程序中访问搜索滑块更改事件.

我知道这是一个非常简单的问题,我从3小时开始研究它,但却无法使其正常工作.我试图实现UIAlertController使用Apple文档显示错误消息,但我在这一行上得到错误,没有已知的选择器presentViewController的类方法[self presentViewController:alert animated:YES completion:nil];我搜索并获得了许多解决方案,但没有在这里工作.AlertMessageViewController是我的自定义类,它继承自UIViewController.
AlertMessageViewController.h
#import <UIKit/UIKit.h>
@interface AlertMessageViewController : UIViewController
+(instancetype)showAlert: (NSString *) title withMessage: (NSString*) message preferredStyle:(UIAlertControllerStyle)preferredStyle;
@end
AlertMessageViewController.m
#import "AlertMessageViewController.h"
#import <UIKit/UIKit.h>
@interface AlertMessageViewController ()
@end
@implementation AlertMessageViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
+(instancetype)showAlert: (NSString *) title withMessage: (NSString*) message preferredStyle:(UIAlertControllerStyle)preferredStyle
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:@"alertMessage" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){NSLog(@"ok action");}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
@end
Run Code Online (Sandbox Code Playgroud)