使用PickerView时获得3个警告

时间:2013-08-13 17:32:17

标签: ios warnings uipickerview

当我使用这段代码时,我在实现中得到三个警告说不完整的实现,未实现protocool中的方法pageViewController:viewControllerAfterViewController,未实现protocool中的方法pageViewController:viewControllerBeforeViewController。我不知道为什么会发生这种情况

这是我的头文件

    IBOutlet UIPickerView     *SaveTopicker;
    NSMutableArray            *arraygenre;
}

@property(nonatomic, retain) AVCaptureStillImageOutput *stillImageOutput;
@property (weak, nonatomic) IBOutlet UILabel *categoryLabel;

@property (weak, nonatomic) IBOutlet UIView *imagePreview;
@property (weak, nonatomic) IBOutlet UIView *saveImage;
@property (weak, nonatomic) IBOutlet UIImageView *captureImage;
@property (weak, nonatomic) IBOutlet UISegmentedControl *cameraSwitch;
@property (weak, nonatomic) IBOutlet UIView *pickerViewContainer;

@property (nonatomic, retain) UIAccelerometer *accelerometer;
@property (weak,nonatomic) IBOutlet UIScrollView *BGScrollView;
- (IBAction)saveButton:(id)sender;
- (IBAction)closeButton:(id)sender;

@property (retain, nonatomic) UIImage *yourImage;



- (IBAction)switchCamera:(id)sender;
- (IBAction)snapImage:(id)sender;

@end

这是我的实施文件     @implementation ViewController

@synthesize accelerometer, stillImageOutput, imagePreview, captureImage, cameraSwitch, pickerViewContainer;

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {

    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {

    if (component == genre)
        return [arraygenre count];

    return 0;
}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {

    if (component == genre)
        return [arraygenre objectAtIndex:row];
    return 0;
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;


}

- (IBAction)saveButton:(id)sender {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    pickerViewContainer.frame = CGRectMake(0, 307, 320, 261);
    [UIView commitAnimations];
}

- (IBAction)closeButton:(id)sender {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    pickerViewContainer.frame = CGRectMake(0, 460, 320, 261);
    [UIView commitAnimations];
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    NSArray  *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    //fetch Category Name from the array used to fill the Picker View
    NSString *categoryName= [arraygenre objectAtIndex:row];
    NSString *fPath = [documentsDirectory stringByAppendingPathComponent:categoryName];
    NSFileManager *fileManager=[[NSFileManager alloc]init];
    [fileManager createDirectoryAtPath:fPath withIntermediateDirectories:YES attributes:nil error:nil];

    UIImage *image = captureImage.image;
    NSData *data = UIImagePNGRepresentation(image);
    [data writeToFile:fPath atomically:YES];

}

2 个答案:

答案 0 :(得分:1)

您已将您的类声明为实施UIPageViewControllerDataSource协议,这使您有义务实施这些方法。如果您实际上不想成为UIPageViewController的数据源,请删除对协议的引用,或者在需要时实现这些方法。

答案 1 :(得分:0)

您正在尝试设置UIPicker委托,而是执行PageControl委托。要撤消此操作,您必须找到您声明PageviewControllerDelegate的位置并将其删除。然后插入选择器代表。