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 7583869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:47:10+00:00 2026-05-30T18:47:10+00:00

I am doing an iPad app, were i will have UITabelview and a Button

  • 0

I am doing an iPad app, were i will have UITabelview and a Button and UiTextview in same screen. My task is that if i select some row in UITableview and press button the text has to be appeared on the UITextview.

I filled few methods but it didn’t work can any one let me know what exactly i can do to complete this task successfully.

Please find my code below for your reference…it may help you to explain my problem.

#import <UIKit/UIKit.h>
#import "table1.h"
#import "textView.h"


@interface searchOne : UIViewController

{
    IBOutlet UITableView *firstTable;
    table1 *tableOne;
    textView * text1;
    int row;
}
@property(nonatomic,retain)IBOutlet UIButton * search;
@property (nonatomic,retain) IBOutlet UITextView *txt;
@property(nonatomic, assign) int row;

-(IBAction)resPage:(id)sender;
@end
#import "searchOne.h"
#import "textView.h"

@implementation searchOne
@synthesize search;
@synthesize txt, row;


- (void)viewDidLoad {
    [super viewDidLoad];
    if (tableOne == nil) {
        tableOne = [[table1 alloc] init];
    }

    [firstTable setDataSource:tableOne];

    tableOne.view = tableOne.tableView;

}

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

    row = [indexPath row];


}   
-(IBAction)resPage:(id)sender{

    NSString *str = txt.text;
    row  = [str intValue];   
    NSLog(@"get clicked");
    self.view =txt;

}

/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */

- (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.
}



- (void)viewDidUnload {
// [self setTxt:nil];
[super viewDidUnload];
                         }
@end

DB:

#import <Foundation/Foundation.h>

@interface db : NSObject{
    NSInteger ID;
    NSString * name;
}


@property (nonatomic, retain) NSString * name;
@property(nonatomic, readwrite) NSInteger ID;



-(id)initWithID: (NSInteger)i andName:(NSString *)n;

@end
@implementation db
@synthesize name,ID;

-(id)initWithID: (NSInteger)i andName:(NSString *)n{
    self=[super init];
    if(self)
    {
        self.ID = i;
        self.name = n;
    }
    return self;
}


@end

Tabel view:

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

@interface table1 : UITableViewController<UITableViewDataSource>{
    NSString *databaseName;
    NSString * databasePath;
    NSMutableArray * tableOne;

}
@property(nonatomic, retain)  NSMutableArray * tableOne;


-(void)checkAndCreateDatabase;
-(void)readDataFromDatabase;


@end

#import "table1.h"
#import "db.h"

@implementation table1
@synthesize tableTwo;

#pragma mark - View lifecycle
- (void)viewDidLoad
{

    databaseName=@"nobel10.db";

    NSArray *documentPaths= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString * documentDir = [documentPaths objectAtIndex:0];
    databasePath=[documentDir stringByAppendingPathComponent:databaseName];
    [self checkAndCreateDatabase];
    [self readDataFromDatabase];
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}


#pragma mark - TableView Data Source methods
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [tableTwo count]; }

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell= nil;
    cell = [tableView dequeueReusableCellWithIdentifier:@"mycell"];
    if (cell == nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mycell"];}

    db * temp =(db *)[self.tableTwo objectAtIndex:indexPath.row];
    cell.textLabel.text=temp.name;
    return cell;
}


-(void)checkAndCreateDatabase{
    BOOL success;
    NSFileManager *fileManager=[NSFileManager defaultManager];
    success=[fileManager fileExistsAtPath:databasePath];
    if(success)
        return;

    NSString *databasePathFromApp = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:databaseName];
    [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
}
-(void)readDataFromDatabase{
    sqlite3 *database;
    tableTwo=[[NSMutableArray alloc]init];
    if(sqlite3_open([databasePath UTF8String], &database)== SQLITE_OK){
        const char *sqlStatement = "SELECT * FROM country";
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL)==SQLITE_OK){
            while (sqlite3_step(compiledStatement)==SQLITE_ROW) {
                NSInteger pId = sqlite3_column_int(compiledStatement, 0);
                NSString *stringName=[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
                db *info =[[db alloc]initWithID:pId andName:stringName];
                [tableTwo addObject:info];

            }            
        }
        sqlite3_finalize(compiledStatement);
    }
    sqlite3_close(database);
}



@end

UITextView:

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

@interface textView : UIViewController<UITextViewDelegate>{
    NSString *databaseName;
    NSString * databasePath;
    NSMutableArray *textOne;
   NSString *description;
}
@property(nonatomic, retain) NSMutableArray *textOne;
@property (nonatomic, retain) NSString *description;
-(void)checkAndCreateDatabase;
-(void)readDataFromDatabase;
-(id)initWithDescription:(NSString *)d;
@end

#import "textView.h"

@implementation textView
@synthesize textOne, description;;
#pragma mark - View lifecycle
- (void)viewDidLoad
{

    databaseName=@"nobel10.db";

    NSArray *documentPaths= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString * documentDir = [documentPaths objectAtIndex:0];
    databasePath=[documentDir stringByAppendingPathComponent:databaseName];
    [self checkAndCreateDatabase];
    [self readDataFromDatabase];
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}


#pragma mark - TableView Data Source methods


// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)


-(void)checkAndCreateDatabase{
    BOOL success;
    NSFileManager *fileManager=[NSFileManager defaultManager];
    success=[fileManager fileExistsAtPath:databasePath];
    if(success)
        return;

    NSString *databasePathFromApp = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:databaseName];
    [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
}
-(void)readDataFromDatabase{
    sqlite3 *database;
    textOne=[[NSMutableArray alloc]init];
    if(sqlite3_open([databasePath UTF8String], &database)== SQLITE_OK){
        const char *sqlStatement = "SELECT name,item_country.id,text.item FROM country,item_country,text WHERE country.name ='India' AND country.id = item_country.id AND text.item =item_country.item ";
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL)==SQLITE_OK){
            while (sqlite3_step(compiledStatement)==SQLITE_ROW) {
                NSInteger pId = sqlite3_column_int(compiledStatement, 0);
                NSString *stringName=[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
                db *info =[[db alloc]initWithID:pId andName:stringName];
                [textOne addObject:info];

            }            
        }
        sqlite3_finalize(compiledStatement);
    }
    sqlite3_close(database);
}
-(id)initWithDescription:(NSString *)d{
self.description = d;
    return self;
}

@end

PLease help me i am new to iPad development and struck here..

  • 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-05-30T18:47:12+00:00Added an answer on May 30, 2026 at 6:47 pm

    A quick and dirty way is just to remove the UITextView, and add it back in when you select the row. See if that works.

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

Sidebar

Related Questions

I have a Core Data app that will end up being an iPhone/iPad universal
I'm designing an iPad app that will have a custom grid in it. The
I would like to make a button in my iPad app (probably will be
I am doing an iPad app based on a UISplitViewController. I have a little
In my iPad app... I am doing some stuff of dragging an object.... My
I have an iPad app that receives data using UDP sockets. And it has
In my current Ipad app, I have a split screen view in which the
I have a software that eventually will have some reports to be accessed via
I have this app of mine that contains a section that will allow the
I'm developing an iPad app that allows a user to select widgets to appear

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.