1

当我使用此代码时,我在实现时收到三个警告,说实现不完整,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 视图控制器

@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];

}
4

2 回答 2

1

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

于 2013-08-13T17:37:04.123 回答
0

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

于 2013-08-13T17:36:46.183 回答