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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:14:38+00:00 2026-05-16T07:14:38+00:00

I am trying to create a contacts like app for iphone where the name

  • 0

I am trying to create a contacts like app for iphone where the name of contact is displayed on the top (to do this I am writing code in viewForHeaderInSection) and then the details follows in the grouped section. The problem is I am retrieving the values from database and if the first name is null it is displayed on the table. I want to delete the null values and display the fields which has values in it. The names are saved in an array. I am trying to get the following fields from the database to display on the table.

NSMutableArray *nameSectionDetails=[[NSMutableArray alloc]initWithObjects:[eachContact objectAtIndex:0], [eachContact objectAtIndex:1], [eachContact objectAtIndex:2],[eachContact objectAtIndex:3],[eachContact objectAtIndex:4],[eachContact objectAtIndex:19],nil];

NSMutableDictionary *nameSection = [[NSMutableDictionary alloc]initWithObjectsAndKeys: nameSectionDetails, @”name”, nil];
self.labelSection=nameSection;

eachContact has all the details of a particular contact.

This is where I am trying to display

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
 if(section == 0) {
  // create the parent view that will hold 1 or more buttons
  UIView* buttonView = [[[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 100.0)]autorelease];

  UILabel *updateDeletedLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 60.0)] autorelease];
  /*updateDeletedLabel.text = [NSString stringWithFormat:@"%@\n%@ %@\n%@\n%@",[eachContact objectAtIndex:1],[eachContact objectAtIndex:3],[eachContact objectAtIndex:2],[eachContact objectAtIndex:3],[eachContact objectAtIndex:4],[eachContact objectAtIndex:19]];*/
  /*for(int i=1;i<[[labelSection objectForKey:@"name"]count];i++)
  {
   if([[[labelSection objectForKey:@"name"]objectAtIndex:i] isEqualToString:@"(null)"])
    [[labelSection objectForKey:@"name"]removeObjectAtIndex:i];
   //i+=i*i;

  }*/


  updateDeletedLabel.text=[NSString stringWithFormat:@"%@ %@ %@\n%@\n%@\n%@",[[labelSection objectForKey:@"name"]objectAtIndex:1],[[labelSection objectForKey:@"name"]objectAtIndex:3],[[labelSection objectForKey:@"name"]objectAtIndex:5],[[labelSection objectForKey:@"name"]objectAtIndex:7],[[labelSection objectForKey:@"name"]objectAtIndex:9],[[labelSection objectForKey:@"name"]objectAtIndex:11]];

  updateDeletedLabel.font = [UIFont systemFontOfSize:12];
  updateDeletedLabel.numberOfLines = 0;
  updateDeletedLabel.lineBreakMode = UILineBreakModeWordWrap;
  updateDeletedLabel.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
  [updateDeletedLabel setTextAlignment: UITextAlignmentCenter];

  // add the button to the parent view

  [buttonView addSubview:updateDeletedLabel];

  return buttonView;
 }
 return nil;
}

Can anyone please help me in this regard. I am a newbie learning iphone applications and if you can suggest any other method, I am glad to know that. Thanks!!!

  • 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-16T07:14:39+00:00Added an answer on May 16, 2026 at 7:14 am

    You should learn about customizing UITableCells

    see http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html#//apple_ref/doc/uid/TP40007451

    especially this code: http://developer.apple.com/iphone/library/samplecode/TableViewSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007318

    edit after clarification in comments

    Still you should go the the mentioned documentation, as you are using the tableview wrong.

    In the headerview for section 0 you would only return a view, that displays the photo and the name. (probably using a custom view loaded from a nib file)

    the cells you would create in –tableView:cellForRowAtIndexPath:

    edit

    I was curious, what it does really take to do an app like that. Here are the results

    THIS IS NOT READY FOR PRODUCTION — if name, familyname or pictureurl won’t be provided, the DetailView will crash

              By using this code, you agree in doing your 
              homework and study the mentioned documentation!

    screenshot

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

Sidebar

Related Questions

I'm trying to create a small app for users to have contacts. I'm using
I'm trying to create a contact form. However at the top of the form
So I have this iPhone app with a nested setup like this: [RootViewController]->[UITabBarController]->[UINavigationController]->[subViewControllers]. Everything
Trying to create a starter app with PhoneGap. I'm stuck on this line: navigator.device.capture.captureAudio(onSuccess,
I am trying to create a contact which is a has_one relation to a
I'm trying to create a new contact and add it to the AddressBook but
Trying to create a facebook app just to learn and coming across a strange
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm writing an Android app that contains a contact list. The design required me
I am trying to create a way a user can contact a friend via

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.