0
我有標籤的基於應用程序,我需要在點擊按鈕pickerview表現爲動作片奇怪的輸出UIPickerView
我用下面的代碼
-(IBAction)DisplayPicker:(id)sender{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 20, 20);
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
[pickerView release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
的問題,當點擊該按鈕線出現,而不是pickerview
如何解決這個請,我爲iPad開發 我用下面的委託功能
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog([arrayNo objectAtIndex:row]) ;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [arrayNo count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [arrayNo objectAtIndex:row];
}
,我初始化arrayNo使用
arrayNo = [[NSMutableArray alloc] init];
[arrayNo addObject:@" 100 "];
[arrayNo addObject:@" 200 "];
[arrayNo addObject:@" 400 "];
[arrayNo addObject:@" 600 "];
[arrayNo addObject:@" 1000 "];
它appeaered分開的選擇器,但不是全部,甚至增加它後,你可以嘗試 – AMH 2011-04-28 10:25:19
當我是你的代碼粘貼到它顯示的選擇器正確,只要我行註釋掉一個新項目將dataSource和delegate設置爲self。如果你註釋掉這些行,然後選擇器是正確的大小(但是空的),那麼你應該看看你的數據源和委託方法。 – Walter 2011-04-28 11:18:45
我用我使用的委託功能更新了這個問題,你能幫我做些什麼: – AMH 2011-04-28 11:55:57