为什么选择器视图不显示数据?

时间:2014-06-11 04:19:40

标签: iphone objective-c xcode ipad ios7

我有一个按钮,当按下时显示视图。在视图内部,有选择器视图和工具栏.PickerView不显示数据。我找不到数据没有出现的原因。有人可以帮帮我吗?

我的RealViewController.h

#define option1 2

@interface RealViewController : UIViewController
<NSURLConnectionDelegate,UIPickerViewDataSource,UIPickerViewDelegate>
{
NSMutableArray *arrayOption;
IBOutlet UIPickerView *pickerOutlet1;
}

@property (strong, nonatomic) IBOutlet UIButton *buttonOption;
@property (strong, nonatomic) IBOutlet UIView *viewContainer;
-(IBAction)showViewContainer;
-(IBAction)hideViewContainer;
@end

我的RealViewController.m文件

-(NSInteger)numberOfComponentsInPickerView:(UIViewController *)pickerView{
 return 1;
}
-(NSInteger)pickerView:(UIViewController *)pickerView numberOfRowsInComponent:(NSInteger)component{
if(component==option1)
        return[arrayOption count];
}
-(NSString *)pickerView:(UIViewController *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
if(component==option1)
        return[arrayOption objectAtIndex:row];
}
-(IBAction)showViewContainer
{
_viewContainer.layer.hidden=NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
_viewContainer.frame=CGRectMake(0,767,768,258);
}
-(IBAction)hideViewContainer
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
_viewContainer.frame=CGRectMake(0,10000,320,206);
}

- (void)viewDidLoad
{
[super viewDidLoad];
arrayOption=[[NSMutableArray alloc]init];
[arrayOption addObject:@"qwerty1"];
[arrayOption addObject:@"qwerty2"];
[arrayOption addObject:@"qwerty3"];
[arrayOption addObject:@"qwerty4"];
}

好的,我发现了自己的错误 而不是#define option1 2必须有option1 0.那就是它。

0 个答案:

没有答案