ios - 双(双组件)选择器 View 的问题
<p><p>我正在使用双(双组件)选择器 View 。当我运行它时,它会显示双选择器 View ,但两个组件的行中的信息相同。</p>
<p>这是代码希望你能帮助我。<br/>
我想在第一个组件中显示 array1,在第二个组件中显示 array2。</p>
<pre><code>- (void)viewDidLoad {
NSArray *FirstArray1 = [ initWithObjects:
@"White",@"Whole Wheat",@"Rye",@"Sourdough",@"Seven Grain", nil];
self.Array1 = FirstArray1;
NSArray *FirstArray2 = [ initWithObjects:
@"Turkey",@"Peanut Butter",@"Tuna Salad",@"Chicken Salad",@"Roast Beef",
@"Vegemite",nil];
self.Array2 = FirstArray2;
;
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 2;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return;
return;
}
-(NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
return ;
return ;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>-(NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
if (component == 0) {
return;
} else if (component == 1) {
return;
}
return 0;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 双(双组件)选择器 View 的问题,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/9199891/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/9199891/
</a>
</p>
页:
[1]