2014-10-03 2 views
-1

그래서, 나는 sqliteDB와 함께 응용 프로그램을 가지고 있는데, 응용 프로그램에서 작성한 채우기, 예를 들어 Name, Lastname입니다. 이제는 양식에 피커 뷰를 추가하려고 시도하지만 실제로 어떻게 작업 할 수 있는지 잘 모릅니다. 이 버튼은 텍스트 필드의 입력 데이터를 처리합니다. 여기에 동일한 선택기를 추가했지만 아무 일도 일어나지 않았습니다. 아마도, 나는 대신 "???" ? ".dataSourse"를 시도했지만 아무 일도 일어나지 않습니다.난 꽤 이해가 안 돼요 UIPickerView

- (IBAction)saveInfo:(id)sender { 
NSString *query; 
if (self.recordIDToEdit == -1) { 
    query = [NSString stringWithFormat:@"insert into peopleInfo values(null, '%@', '%@', '%@', '%s')", self.txtFirstname.text, self.txtLastname.text, self.txtCategory.text, self.txtPicker.???; 
} 
else{ 
    query = [NSString stringWithFormat:@"update peopleInfo set firstname='%@', lastname='%@', category='%@', suka='%s' where peopleInfoID=%d", self.txtFirstname.text, self.txtLastname.text, self.txtCategory.text, self.txtPicker.???, self.recordIDToEdit]; 
} 

내가 발표 한 *

NSString *select = [_array objectAtIndex:[_txtPicker selectedRowInComponent:0]]; 

그렇게하지 않을 수 있습니다 .. 이러한 선택 값을 선택,하지만 난 텍스트 필드에서 다른 데이터처럼 내 DB에 추가 방법을 모른다 데이터베이스에 데이터를 추가 하시겠습니까?

+1

huh whatt ?? 피커가 어디입니까? – meda

+0

피커가 콘센트로 txtPicker와 일치 –

+0

문자열에 UIPicker를 넣으려고합니까? 당신의 목표를 설명하십시오 – meda

답변

0

당신은에서 선택한 행 인덱스 얻을 수 있습니다 : 예를 들어

- (NSInteger)selectedRowInComponent:(NSInteger)component; 

을 :

int index = [txtPickerselectedRowInComponent:0]; 
self.strTx= [pickerData objectAtIndex:index]; 

또는 사용 위임 : 누군가가 당신의 선택 도구에서 항목을 선택 기본적으로

- (void)pickerView:(UIPickerView *)pickerView 
         didSelectRow:(NSInteger)row inComponent:(NSInteger)component; 

, 값을 읽으십시오.

self.strTx= [pickerData objectAtIndex:row]; 

선택의 여지가 있습니다

관련 문제