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

  • Home
  • SEARCH
  • 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 6970079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:39:50+00:00 2026-05-27T16:39:50+00:00

I have 2 view controller pages.Add Reminder page which contains save button as right

  • 0

I have 2 view controller pages.Add Reminder page which contains save button as right bar button of navigation bar

I have earlier got issues regarding number of sections in table view for view reminder page based on number of saves in add reminder page:

I found out the solution for generating cells based on number of saved reminders

this is the code:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)view
{
NSInteger numTableRecords = -1;
    sqlite3_stmt *statement;
    if (sqlite3_open([self.databasePath UTF8String], &remindersDB) == SQLITE_OK) 
    {
        NSString *sqlStatement = [NSString stringWithFormat: @"select count(*) from reminders"];
        const char *sql = [sqlStatement cStringUsingEncoding:NSUTF8StringEncoding];
        if(sqlite3_prepare_v2(remindersDB, sql, -1, &statement, NULL) == SQLITE_OK) 
        {          
            while(sqlite3_step(statement) == SQLITE_ROW) 
            {
                numTableRecords = sqlite3_column_int(statement, 0);
            }
        }
        else 
        {
            printf("could not prepare statement: %s\n", sqlite3_errmsg(remindersDB));
        }
    }

    else 
    {
        NSLog(@"Error in Opening Database File");
    }
    sqlite3_close(remindersDB);
    return numTableRecords; 
}

Now my problem here is I am able to retrieve the data,but not in a proper way.I mean this is the code I used to retrieve the data

if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellId] autorelease];
        view.backgroundColor = [UIColor clearColor];
        cell.backgroundColor = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"reminderbutton.png"]];

        label1 = [[[UILabel alloc]initWithFrame:CGRectMake(26, 3, 30, 40)]autorelease];
        label1.backgroundColor = [UIColor clearColor];
        label1.textColor = [UIColor whiteColor];

        label2 = [[[UILabel alloc]initWithFrame:CGRectMake(45, 3, 100, 40)]autorelease];
        label2.backgroundColor = [UIColor clearColor];
        label2.textColor = [UIColor whiteColor];

        label3 = [[[UILabel alloc]initWithFrame:CGRectMake(119, 3, 100, 40)]autorelease];
        label3.backgroundColor = [UIColor clearColor];
        label3.textColor = [UIColor whiteColor];

        label4 = [[[UILabel alloc]initWithFrame:CGRectMake(198, 3, 120, 40)]autorelease];
        label4.backgroundColor = [UIColor clearColor];
        label4.textColor = [UIColor whiteColor];

        //Retrieve the values of database
        const char *dbpath = [self.databasePath UTF8String];
        sqlite3_stmt *statement;

        if (sqlite3_open(dbpath, &remindersDB) == SQLITE_OK)
        {
            NSString *querySQL = [NSString stringWithFormat:@"SELECT * from reminders ORDER BY id"];

            const char *query_stmt = [querySQL UTF8String];

            if (sqlite3_prepare_v2(self.remindersDB ,query_stmt , -1, &statement, NULL) == SQLITE_OK)
            {
                if (sqlite3_step(statement) == SQLITE_ROW)
                {
                    NSString *ID = [[[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)]autorelease];

                    NSString *nameField = [[[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 1)]autorelease];                    

                    NSString *eventField = [[[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)]autorelease];

                    NSString *dateField = [[[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(statement, 3)]autorelease];

                    label1.text = ID;
                    label2.text = nameField;
                    label3.text = eventField;
                    label4.text = dateField;
                } 

                sqlite3_finalize(statement);
            }
            sqlite3_close(self.remindersDB);
        }


                    [cell addSubview:label1];
                    [cell addSubview:label2];
                    [cell addSubview:label3];
                    [cell addSubview:label4];

    }

    return cell;

I have inserted 4 reminders,the 4 cells are appearing,but the problem is with displaying

It is appearing as following

enter image description here

How can I get the 4 reminders displayed in 4 cells consecutively,I mean the 1st reminder on 1st,2nd reminder on 2nd and so on..

Please help me to fix this issue,thanks all in advance 🙂

Sorry all…I found out the complete solution to the issue in the following link:

Retrieve all rows inserted in sqlite database and display in table view cells containing labels as subviews with different sections

Sorry for the question…Thanks every one who viewed this,take it If useful

Hence I am not removing this question,bye TC 🙂

  • 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-27T16:39:51+00:00Added an answer on May 27, 2026 at 4:39 pm

    I’m giving you one suggestion just try it. I hope it will work.

    Do one thing, just retrieve data from sqlite in viewDidAppear or viewWillAppear and save the data in an nsmutableArray.

    Then in - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section just return [yourArray count].

    and for reloading table just try with [self.tableview reloadData]

    I hope it’ll be work. just let me know for any further clarification.

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

Sidebar

Related Questions

I have a controller's action and view page that uses a master page. The
Hi I have a tabbar controller which includes two pages A and B. Now
I have an attribute to add a page to my site's navigation (its a
I would like to have a view (Hierarchy structure) under Navigation Controller (the top
I have View Controller with a (navigation controller) that can flip between 2 views
I have view controller, into the view i have put a table view, and
I have two view controller classes in my application delegate. I can change from
I have a view controller and I am intercepting the touches on links within
I have a view controller class that has to implement several protocols. Too keep
I have a view controller that gets presented modally and changes some data that

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.