에서 나는 saveInfo버튼을 클릭하여 sqlite3를 데이터베이스에 내 이미지와 텍스트를 저장했습니다.IOS 이미지 표시 SQLite는 데이터베이스
- (IBAction)saveInfo:(id)sender {
// Prepare the query string.
NSString *query;
if (self.recordIDToEdit == -1) {
query = [NSString stringWithFormat:@"insert into empInfo values('%@', '%@','%@','%@','%@','%@')", self.txtEmpCode.text, self.txtName.text, self.txtDesignation.text,self.txtDepartment.text,self.txtTagline.text,self.saveImage.image];
}
else{
query = [NSString stringWithFormat:@"update empInfo set name='%@',empInfoCode='%@',designation='%@',department='%@',tagLine='%@',photo='%@' where empInfoCode=%d", self.txtEmpCode.text,self.txtName.text, self.txtDesignation.text,self.txtTagline.text,self.txtDepartment.text,self.saveImage.image, self.recordIDToEdit];
}
// Execute the query.--------------
[self.dbManager executeQuery:query];
// If the query is sucessfull the show this in the dubugger.
if (self.dbManager.affectedRows != 0) {
NSLog(@"Query was executed successfully. Affected rows = %d", self.dbManager.affectedRows);
// Here we inform the delegate that editing in app is finished.
[self.delegate editingInfoWasFinished];
// Pop the view controller.
[self.navigationController popViewControllerAnimated:YES];
}
else{
NSLog(@"%d",self.dbManager.affectedRows);
NSLog(@"---Could not execute the query.----");
}
}
가 그럼 난이 방법에서 데이터를로드, 나는 텍스트 데이터에 액세스 할 수 있어요하지만이 방법의 이미지를로드 할 수 없습니다.
-(void)loadInfoToEdit{
// Create the query.
NSString *query = [NSString stringWithFormat:@"select * from empInfo where empInfoCode=%d", self.recordIDToEdit];
// Load the relevant data.
NSArray *results = [[NSArray alloc] initWithArray:[self.dbManager loadDataFromDB:query]];
// Setting the loaded data to the textfields and imageView.
.
self.txtEmpCode.text = [[results objectAtIndex:0] objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"empInfoCode"]];
self.txtName.text = [[results objectAtIndex:0] objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"name"]];
self.txtDesignation.text = [[results objectAtIndex:0] objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"designation"]];
self.txtTagline.text = [[results objectAtIndex:0] objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"tagLine"]];
self.txtDepartment.text = [[results objectAtIndex:0] objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"department"]];
self.saveImage.image = [[results objectAtIndex:0] objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"photo"]];
// NSLog(@"This photo has:%@",[[results objectAtIndex:0]objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"photo"]]);
// self.saveImage.image= [[results objectAtIndex:0]objectAtIndex:[self.dbManager.arrColumnNames indexOfObject:@"photo"]];
// NSLog(@"This Nsdata object has %@",img);
// self.saveImage.image = [UIImage imageWithData:img];
}
어떻게로드 할 수 saveImage (UIImageView에 속성)에 내 이미지 ?
덕분에 많이 @Lion. –
환영합니다 ... :) – Lion
다음 이미지를 삽입하려고하면 이미지를 업데이트 할 수 없습니까? 마지막 사람을 위해 삽입 된 동일한 이미지를 보여줍니다. –