0
根据我的项目需求,我正在开发一个使用UIPickerview
的应用程序。我想从服务器下载pdf。我正在开发代码,但发生错误。请帮助我一个人。 我是编程新手。如何使用uipickerview检索网址
pdfviewcontroller.m
-
#define kStringURLViewControllerPDF @"https://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIViewController_Class/UIViewController_Class.pdf"
#define kStringURLQLPreviewControllerPDF @"https://developer.apple.com/library/ios/DOCUMENTATION/NetworkingInternet/Reference/QLPreviewController_Class/QLPreviewController_Class.pdf"
- (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return [listArray count];
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [listArray objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSLog(@"Selected Color: %@. Index of selected color: %i", [listArray objectAtIndex:row], row);
switch (component.row) {
case 0:
url = [NSURL URLWithString:kStringURLViewControllerPDF];
break;
case 1:
url = [NSURL URLWithString:kStringURLQLPreviewControllerPDF];
break;
case 2:
url = [NSURL URLWithString:kStringURLUIDocumentInteractionControllerPDF];
break;
}
}
您的问题缺失,就像您遇到的错误。 – rckoenes
'kStringURLUidocumentInteractionControllerPDF'没有被定义在任何地方 –
你必须定义这个#define kStringURLUidocumentInteractionControllerPDF @“url” –