如何使用uipickerview检索网址

时间:2013-05-30 09:35:16

标签: iphone objective-c

我正在根据我的项目要求使用UIPickerview开发一个应用程序。我想从server下载pdf。我正在开发代码,但是发生了错误。请帮帮我一个人。 我是编程新手。

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;

    }
}

1 个答案:

答案 0 :(得分:0)

一个错误是kStringURLUIDocumentInteractionControllerPDF未在上面定义。 如果您使用您正在获得的错误更新问题,我们可以更好地帮助您。