[英]How can i select the complete row for different components in UIPickerView?
[英]How can I get the row number of each components in UIPickerView
如何獲取UIPickerView
中每個組件的行號?
我有UIPickerView
Whit 3組件:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
第二個問題是我如何改變每個組件的寬度?
您可能正在從數組中填充UIPickerView; 在調用中使用row
參數
[dataArray objectAtIndex:row];
獲取數據。 如果您需要知道總行數,只需使用[dataArray count];
獲取數據源的大小。
編輯:我忘記了如果您遵循協議,您將實現此方法:
-(NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
NSInteger numRows = 0;
switch (component) {
case 0:
numRows = 6;
break;
case 1:
numRows = 3;
break;
case 2:
numRows = 2;
break;
default:
break;
}
return numRows;
}
所以,你實際上是告訴系統每個組件有多少行。 進行檢查,或繼續實施,您將得到答案!
編輯2:如果要獲取每個組件中當前選定的行,請使用:
[yourPickerView selectedRowInComponent:1];
根據需要多次。 我建議循環遍歷所有組件並使用此方法來獲取選定的行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.