Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8927791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:17:32+00:00 2026-06-15T08:17:32+00:00

I am creating an email signature, i have made two view’s till now ViewController

  • 0

I am creating an email signature, i have made two view’s till now “ViewController and “ListView” coding is like this

ViewController.h

 #import <UIKit/UIKit.h>
 #import "ListView.h"
 #import "sqlite3.h"

@interface ViewController:UIViewController<UITextViewDelegate,UIImagePickerControllerDelegate>
 {
UIImageView *imageView;
UIImage *signimage;
UIImagePickerController *imagePicker;
NSMutableArray *hello;
NSMutableArray *hellocontent;

ListView *listview;
UITextField *signaturename;
UITextView *textView; // UITextView *scontent;
 // IBOutlet UIScrollView *scrollview;
 // BOOL keyboardIsShown;
  //IBOutlet UITextField *recordTextField;

NSString   *databasePath;
sqlite3 *Dummy2;
 }
 @property(nonatomic,retain) IBOutlet UIImageView *imageView;
 @property(nonatomic,retain) UIImage *signimage;
 -(IBAction)btnLoadImage:(id) sender;
  -(IBAction)clearFields:(id)sender;
  -(IBAction)show:(id)sender;
 // @property (nonatomic,retain) UITextField *recordsTextField;

 //@property(nonatomic,retain) IBOutlet UIScrollView *scrollview;
   @property(nonatomic, retain) IBOutlet UITextField *signaturename;
   @property(nonatomic, retain) IBOutlet UITextView *textView;  // scontent

   -(IBAction) btnsave:(id) sender;
    -(IBAction) keyboard:(id) sender;
    -(IBAction)next:(id)sender;

  -(IBAction) bgtouch:(id) sender;
   // -(IBAction)show:(id)sender;
   // -(IBAction)records:(id)s;
   // -(IBAction)updateQuery:(id)sender;

   //Static methods.
   + (void) getInitialDataToDisplay:(NSString *)dbPath;
   + (void) finalizeStatements;

   //Instance methods.
   - (id) initWithPrimaryKey:(NSInteger)pk;
    - (void) saveAllData;


   @end

ViewController.m

#import "ViewController.h"
#import"ListView.h"

 @implementation ViewController
 @synthesize signaturename,imageView,textView,signimage; // recordsTextField


     // scrollview;
   -(IBAction)next:(id)sender{

    sqlite3_stmt    *statement;

    const char *dbpath = [databasePath UTF8String];
     hello = [[NSMutableArray alloc]init]; 
    //  hellocontent = [[NSMutableArray alloc]init];

    if (sqlite3_open(dbpath, &Dummy2) == SQLITE_OK)
   {
    NSString *updateSQL = @"SELECT * FROM PROFILE";

    const char *update_stmt = [updateSQL UTF8String];

    sqlite3_prepare_v2(Dummy2, update_stmt, -1, &statement, NULL);
    while(sqlite3_step(statement) == SQLITE_ROW) {
          [hello addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)]];
    //    [hellocontent addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)]];
    }
    sqlite3_finalize(statement);
    sqlite3_close(Dummy2);
}   
listview = [[ListView alloc]initWithNibName:@"ListView" bundle:nil];
listview.arr=[[NSMutableArray alloc]init];
 listview.arr = hello;

 [self.view addSubview:listview.view];

  }

 - (void)setCoffeeImage:(UIImage *)theCoffeeImage {

// self.isDirty = YES;
[signimage release];
signimage = [theCoffeeImage retain];
  }


  -(IBAction) btnsave:(id) sender
  {

if (([self.signaturename.text length] && [self.textView.text length]) != 0) {

  //  NSData *data = UIImagePNGRepresentation(self.signimage);      


    sqlite3_stmt    *statement;

    const char *dbpath = [databasePath UTF8String];
    hello = [[NSMutableArray alloc]init]; 

    if (sqlite3_open(dbpath, &Dummy2) == SQLITE_OK)
    {


        NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO profile (sname,scontent) VALUES (\"%@\", \"%@\")", signaturename.text,textView.text];

        const char *insert_stmt = [insertSQL UTF8String];                          
       //  sqlite3_bind_blob(statement, 3, [data bytes], [data length], NULL);
        sqlite3_prepare_v2(Dummy2, insert_stmt, -1, &statement, NULL);
        if (sqlite3_step(statement) == SQLITE_DONE)
        {
            // status.text = @"Contact added";
            signaturename.text = @"";            //address.text = @"";
            textView.text = @"";
            // imageUrl.text=@"";

        } else {
            // status.text = @"Failed to add contact";
        }
        sqlite3_finalize(statement);
        sqlite3_close(Dummy2);
    }


       }   
else
    {  
    UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"Warning" message:@"Signature Name and Content Field Should Not Be Empty" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alert show]; 


   }


    }
 -(IBAction)show:(id)sender{
const char *dbpath = [databasePath UTF8String];
sqlite3_stmt    *statement;

if (sqlite3_open(dbpath, &Dummy2) == SQLITE_OK)
{
    NSString *querySQL = [NSString stringWithFormat: @"SELECT sname, scontent FROM profile WHERE sname=\"%@\"", signaturename.text];

    const char *query_stmt = [querySQL UTF8String];

    if (sqlite3_prepare_v2(Dummy2, query_stmt, -1, &statement, NULL) == SQLITE_OK)
    {
        if (sqlite3_step(statement) == SQLITE_ROW)
        {
            NSString *addressField = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 1)];
            textView.text = addressField;


           // status.text = @"Match found";

            [addressField release];

        } else {
          //  status.text = @"Match not found";
           textView.text = @"";

        }
        sqlite3_finalize(statement);
    }
    sqlite3_close(Dummy2);
  }
  }


  -(IBAction)clearFields:(id)sender
   {
signaturename.text=@"";

textView.text=@"";
    NSLog(@"clear is working");


    }

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {

    if([text isEqualToString:@"\n"]) {
    [textView resignFirstResponder];
    return NO;
    }

    return YES;
    }
  -(IBAction) bgtouch:(id) sender
    {
    [signaturename resignFirstResponder];
    // [textView resignFirstResponder];
    }

    -(IBAction) keyboard:(id)sender
     {
    [sender resignFirstResponder];
    // [self.signaturecontent resignFirstResponder];
    }
  - (void)didReceiveMemoryWarning
 {
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}

 #pragma mark - View lifecycle

- (void)viewDidLoad
{
imagePicker =[[UIImagePickerController alloc]init];
[super viewDidLoad];

NSString *docsDir;
NSArray *dirPaths;
// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

docsDir = [dirPaths objectAtIndex:0];

// Build the path to the database file
databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"Dummy2.sqlite"]];

NSFileManager *filemgr = [NSFileManager defaultManager];

if ([filemgr fileExistsAtPath: databasePath ] == NO)
{
    const char *dbpath = [databasePath UTF8String];

    if (sqlite3_open(dbpath, &Dummy2) == SQLITE_OK)
    {
        char *errMsg;
        const char *sql_stmt = "CREATE TABLE IF NOT EXISTS profile(ID INTEGER PRIMARY KEY AUTOINCREMENT, SNAME TEXT, SCONTENT TEXT)";

        if (sqlite3_exec(Dummy2, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK)
        {
           // status.text = @"Failed to create table";
        }

        sqlite3_close(Dummy2);

    } else {
        // status.text = @"Failed to open/create database";
    }
}

[filemgr release];
// Do any additional setup after loading the view, typically from a nib.
  }
  -(IBAction)btnLoadImage:(id)sender
   {
imagePicker.delegate =self;
imagePicker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;

// show the image picker
[self presentModalViewController:imagePicker animated:YES];

   }

   -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
UIImage *image;
NSURL *mediaUrl;
mediaUrl =(NSURL *)[info valueForKey:UIImagePickerControllerMediaURL];

if(mediaUrl == nil){
    image = (UIImage *)[info valueForKey:UIImagePickerControllerEditedImage];
    if(mediaUrl == nil){
        // original image selected
        image =(UIImage *)[info valueForKey:UIImagePickerControllerOriginalImage];

        // display the image
        imageView.image = image;
    }
    else {
        // edited image picked 
        CGRect rect = [[info valueForKey:UIImagePickerControllerCropRect]CGRectValue];

        // display the image
        imageView.image = image;
    }
        }

     // hide the image picker
     [picker dismissModalViewControllerAnimated:YES];
   }
 -(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{
// user did not select image; hide the image picker
[picker dismissModalViewControllerAnimated:YES];
  }
 - (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{

[super viewWillAppear:animated];
}

 - (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{

[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}

 - (BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end

ListView.h

 #import <UIKit/UIKit.h>


 @interface ListView : UIViewController<UITableViewDataSource,UITableViewDelegate>
  {
 NSMutableArray *arr;

 }
@property(nonatomic,retain) NSMutableArray *arr;
-(IBAction)back:(id)sender;
@end

ListView.m

#import "ListView.h"


 @implementation ListView
 @synthesize arr;

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
 }
-(IBAction)back:(id)sender
{
[super.view removeFromSuperview];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//  return 6;

return [arr count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSString *cellvalue = [arr objectAtIndex:indexPath.row];
cell.textLabel.text=cellvalue;
// Configure the cell.
return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

 }



- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
 }

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
 }

- (BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

 @end

Database “Dummy2.sql” is like this

PROFILE = table
id = field = INTEGER PRIMARY KEY
sname = field = TEXT
scontent = field = TEXT
simage = field = BLOB

Schema 
CREATE TABLE PROFILE(id INTEGER PRIMARY KEY, sname TEXT, scontent TEXT, simage BLOB)

This is what i have done so far, what should i code in didselectrowAtIndexpath so that when i select any name from table it should appear in textview in “ListView.xib” … any help also i am not able to save the image in DB i have to show the image also according to the name selected from tableView in “ListView.xib” so that in bottom section i can see the image and content of that name in UIimage and in textview field .. any idea ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:17:34+00:00Added an answer on June 15, 2026 at 8:17 am

    If you want to pass the name to ListView just use the code below:

    Create a object class for holding all data about a person like.

    @interface Person
    
    @property (nonatomic, retain) NSString *name;
    @property (nonatomic, retain) NSString *content;
    @property (nonatomic, assign) int profileId;
    
    @end
    
    @implementation Person
    
    @synthesize name,content;
    @synthesize profileId;
    
    @end
    

    change the data fetching method like:

    Person *person = nil;
    NSString *updateSQL = @"SELECT * FROM PROFILE";
    
    const char *update_stmt = [updateSQL UTF8String];
    
    sqlite3_prepare_v2(Dummy2, update_stmt, -1, &statement, NULL);
    while(sqlite3_step(statement) == SQLITE_ROW) {
          person = [[Person alloc] init];
          [person setProfileId:(int)sqlite3_column_int(statement, 0)];
          [person setName:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)];
          [person setContent:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)];
          [hello addObject:person];
    }
    

    in the tableView class

    Change the cellForRowAtIndexPath like:

    Person *cellvalue = [arr objectAtIndex:indexPath.row];
    cell.textLabel.text=cellvalue.name;
    

    And the didSelectRowAtIndexPath like:

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
     {
        Person *selected = [arr objectAtIndex:indexPath.row];
        txtView.txt =  selected.content
     }
    

    1 Suggestion.

    Don’t save image on database, it’ll make your database too heavy and database operations too slow.

    1 alternative is to save image to document directory and save the path to database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an email like this: System.Diagnostics.Process.Start( string.Format(mailto:{0}?&subject=Test&body={1}, string.Join(, , emails), string.Join(\n, temp.ToArray())
I am creating a JSF form where I have an email field. I need
So I have an html email that I am creating for my company for
I am creating a file to send as an attachment to an email. Now
I am creating Email client using JavaMail API. Everything is working fine like I
I'm creating an email form element like so (inside a Zend Form): //create e-mail
I have seen many examples in Delphi for creating Email sending applications, where we
I have started creating a Perl package that contains a default email template. The
I have an application in which I'm creating an email which I want the
I have been working on creating a PHP email form recently and cannot manage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.