I have saved images in document directory and saved its path in data base successfully now I am not getting that how to show that image in my image view?
Should I use query to select only path?
Will it automatically pick the image from directory?
Or should I use code for load image in my view where I want to show image.
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *strimagename;
strimagename=[NSString stringWithFormat:@"Test.jpg"];
thumbFilePath = [documentsDirectory stringByAppendingPathComponent:strimagename];
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSLog(@"image path: %@ ", [MyCommonFunctions saveImageInDocuments:image]);
imageSelect.image = image;
[self dismissModalViewControllerAnimated:YES];
NSLog(@"image saved %@",image);
}
This above code is for saving.
By using this code in i get this log message for image:
2012-12-08 20:40:30.450 loginApp[757:c07] CONNECTION SUCCESSFUL WITH DB
2012-12-08 20:41:05.371 loginApp[757:c07] image path: 08412012084105.png
2012-12-08 20:41:05.378 loginApp[757:c07] image saved <UIImage: 0x926da00>
Success Query:
insert into login(Name,Email,Password,DOB,image) values('hamesh', 'hamesh@hamesh.com','hamesh','2012-12-09 04:40:57 +0000','<UIImageView: 0x926d8f0; frame = (139 219; 133 115); opaque = NO; autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x926d950>>')
here i am using code that build Sql,in image should i give property NSString? or imageView?
- (IBAction)registerbtn:(id)sender {
DBHandler *db =[[DBHandler alloc]init];
if([self validateForm])
{
if([self validateEmailWithString:txtEmail.text])
{
if ([db authenticateRegistration:txtName.text andEmail:txtEmail.text andPassword:txtPassword.text andDob:txtDob.text andImage:imageSelect])
{
UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:@" Congrats" message:@"SignUp Success" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[loginalert show];
}
else
{
UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:@" Try Again!" message:@"SignUp Failure" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[loginalert show];
}
}
}
Looking at your updated question that includes the
NSLogstatements, it appears that yourNSLogof[MyCommonFunctions saveImageInDocuments:image]is correct. But you also show us the SQL that you’re generating, and it is obviously not using that[MyCommonFunctions saveImageInDocuments:image]for the last parameter, but rather you’re obviously accidentally grabbing aUIImageView. Look at your code that is building that SQL. Update your question with that code that builds your SQL if the solution doesn’t leap out at you.