ios - 使用 PickerView 时收到 3 个警告

标签 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

这是我的实现文件。
@实现 View Controller

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

}

最佳答案

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

关于ios - 使用 PickerView 时收到 3 个警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18215569/

相关文章:

ios - 当我滚动 UIPickerView 时,如何实时获取选定的值

ios - UIPickerView 选择行不起作用 ios7

c++ - 为什么使用 switch-case 时会得到 `warning: control reaches end of non-void function`?

php - "Notice: Undefined variable"、 "Notice: Undefined index"、 "Warning: Undefined array key"和 "Notice: Undefined offset"使用 PHP

php - "Notice: Undefined variable"、 "Notice: Undefined index"、 "Warning: Undefined array key"和 "Notice: Undefined offset"使用 PHP

objective-c - 加载 UIPickerView 后选择行

ios - 关闭 View Controller UI 时卡住

ios - 当应用程序切换到 facebook 进行登录和权限请求时,防止 IOS 关闭应用程序

ios - 如何将值属性绑定(bind)到按钮可见性?

iphone - IOS:以编程方式创建 UI 或使用 Interface builder