gpt4 book ai didi

iphone - 按下按钮时弹出 UIPickerview

转载 作者:行者123 更新时间:2023-12-03 19:10:28 25 4
gpt4 key购买 nike

这段代码有问题吗,因为当我按下按钮弹出UIPickerview时。什么都没发生。这是为什么

  -(void)pickerview:(id)sender
{
items =[[NSArray alloc]initWithObjects:@"Hindi",@"English",nil];

pickerView=[[UIPickerView alloc] initWithFrame:CGRectMake(10,100,150,150)];

pickerView.transform = CGAffineTransformMakeScale(0.75f, 0.75f);

pickerView.delegate = self;

pickerView.dataSource = self;

pickerView.showsSelectionIndicator = YES;

pickerView.backgroundColor = [UIColor clearColor];

[pickerView selectRow:1 inComponent:0 animated:YES];

}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{

return 1;

}

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

return [items count];
}

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

return[items objectAtIndex:row];

}

有人可以告诉我这段代码有什么问题吗?

最佳答案

是的..大问题..

[self.view addSubview:pickerview]; 

缺失

您还确定按下的按钮正在调用此方法吗?它返回 (void) ..如果连接到 xib 组件,它应该显示 IBAction

关于iphone - 按下按钮时弹出 UIPickerview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9572921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com