我正在实施一个AVAssetResourceLoaderDelegate
,而且我在行动方面遇到了一些麻烦.我的目标是拦截AVPlayer发出的任何请求,自己发出请求,将数据写入文件,然后AVPlayer
用文件数据响应.
我看到的问题:我可以拦截第一个请求,它只需要两个字节,然后响应它.在那之后,我没有得到任何更多请求打我的AVAssetResourceLoaderDelegate
.
当我拦截第一个AVAssetResourceLoadingRequest
从AVPlayer
它看起来像这样:
<AVAssetResourceLoadingRequest: 0x17ff9e40,
URL request = <NSMutableURLRequest: 0x17f445a0> { URL: fakeHttp://blah.com/blah/blah.mp3 },
request ID = 1,
content information request = <AVAssetResourceLoadingContentInformationRequest: 0x17ff9f30,
content type = "(null)",
content length = 0,
byte range access supported = NO,
disk caching permitted = NO>,
data request = <AVAssetResourceLoadingDataRequest: 0x17e0d220,
requested offset = 0,
requested length = 2,
current offset = 0>>
Run Code Online (Sandbox Code Playgroud)
如您所见,这只是对前两个字节数据的请求.我正在fakeHttp
使用URL中的协议,将其替换为just http
,并自己发出请求.
然后,这里是我有一些数据后如何响应请求:
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader …
Run Code Online (Sandbox Code Playgroud) 我有一个子类ABPeoplePickerNavigationController
来处理在我的应用程序中选择联系电话号码.iOS 7及更低版本的一切都很棒.
但是,在iOS 8上,我ABPeoplePickerNavigationControllerDelegate
在选择电话号码时不会受到影响.相反,它只是拨打那个电话号码.
我注意到我在iOS 7中使用的用于处理联系人选择的peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
方法在iOS 8中已弃用.此方法已替换为peoplePickerNavigationController:didSelectPerson:property:identifier:
.
我知道我的委托已设置,因为我成功收到peoplePickerNavigationControllerDidCancel:
方法回调.
还有其他人遇到过这个问题吗?
这是我的ABPeoplePickerNavigationController
子类的代码片段:
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
...do stuff...
return NO;
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
return YES;
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
[self dismissViewControllerAnimated:self.shouldAnimateDismiss completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)