0
Goodday,當它保持在底部獲取UIPickerView的價值的UITextField和旋轉
我有以下問題:
在我看來,我有一個texfield,對此我在代碼中創建。的UITextField越來越建立在這樣的代碼:
UITextField *filiaalSelection = [[UITextField alloc] init];
filiaalSelection.frame = CGRectMake(130, 100, 200, 30);
filiaalSelection.borderStyle = UITextBorderStyleLine;
filiaalSelection.delegate = self;
現在,當我開始編輯文本框,一個UIPickerView需要彈出。我在下面的代碼中這樣做:
-(void)textFieldDidBeginEditing:(UITextField *)filiaalSelection {
[filiaalSelection resignFirstResponder];
UIPickerView *myPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, scrollView.frame.size.height - 225, scrollView.frame.size.width, 180)];
[myPicker setDelegate:self];
[myPicker setDataSource:self];
myPicker.showsSelectionIndicator = YES;
[self.view addSubview:myPicker];
}
現在我需要做2件事。首先是: 獲取我的UIPickerView的值並將其插入到UITextField中。下面的方法返回選擇的UIPickerView的當前值:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
[stringsArray objectAtIndex:row];
}
但問題是,我不知道如何將值發送到文本框。而且我還需要在UIPickerView上面完成一個按鈕。這是最好的方法是什麼?
我在另一種方法中製作UITextField:filiaalSelection。所以我不能把價值傳遞給那個..因爲它還沒有被製造出來。 –
您需要將其設置爲可訪問,以便設置它。爲什麼不在頭文件中聲明它? – mjisrawi
Thnx,我在Objective-C方面不是很有經驗。但是,這工作。 –