2013-05-30 28 views
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; 

    } 
} 
+2

您的问题缺失,就像您遇到的错误。 – rckoenes

+0

'kStringURLUidocumentInteractionControllerPDF'没有被定义在任何地方 –

+0

你必须定义这个#define kStringURLUidocumentInteractionControllerPDF @“url” –

回答

0

一个错误将是kStringURLUIDocumentInteractionControllerPDF没有在上面定义的事实。 如果您使用所获得的错误更新问题,我们可以帮助您更好。