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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:20:10+00:00 2026-05-31T22:20:10+00:00

I am trying to create a settings table view for my app. I am

  • 0

I am trying to create a “settings” table view for my app. I am trying to mimic it to be the same style as the gneral setting on an Iphone. I have created my own custom cell class by inheriting from UITableCell. I gave it the appropriate IBOulets and i have hooked them up in the storyboard. I also hooked up the switch to my tableViewControler, but for some reason my code is only returning me one empty cell (it being only one cell is not an issue atm for that’s all i have in my setting). I triple checked and made sure that I’m using the same cell identifier in my code and in storyboard. Anyone know why I’m getting a blank cell back?

Here is my .h file for my custom cell.

@interface NHPSettingsCell : UITableViewCell
@property (nonatomic,weak) IBOutlet UILabel *settingLabel;
@property (nonatomic,strong) IBOutlet UISwitch *settingSwitch;
@end

MY Problem code is here, my .h file for the custom cell:

#import "NHPSettingsCell.h"

@implementation NHPSettingsCell
@synthesize  settingLabel, settingSwitch;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

My method for drawing the cell in my custom view controller:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"SettingsCell";
    NHPSettingsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[NHPSettingsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.selectionStyle = UITableViewCellStyleDefault;
    }
    cell.settingLabel.text = @"firstSetting";

    //check the if user wants promt of disclaimer each time or not.
    if([prefs boolForKey:@"firstSetting"] == YES){
        cell.settingSwitch.on = YES;
    }else{
        cell.settingSwitch.on = NO;
    }

    return cell;
}

Now the thing that annoys me is i have successfully managed to implement the cellForRowAtIndexPath method for a dynamic table that uses custom cells. I have also implements the code for a static table using the default cell, but for a static table with custom cells it just doesn’t seem to work. Here is the code on how I implemented my custom cells on a dynamic table (note how i didn’t have to init the cells but it works).

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"InteractionResultCell";
    NHPResultCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


    // Configure & Fill the cell
    cell.leftLabel.text = [[resultsList objectAtIndex:indexPath.row] substanceName];
    cell.rightLabel.text = [[resultsList objectAtIndex:indexPath.row] substanceName2];
    NSString *color = [NSString stringWithFormat:@"%@", [[resultsList objectAtIndex:indexPath.row] color]];

    //Change a hex value to a readable 0x number to pass ot hte macro so we can go from a hex color to a RGB system.
    NSScanner *scanner;
    unsigned int tempint=0;    
    scanner = [NSScanner scannerWithString:color];
    [scanner scanHexInt:&tempint];

    cell.severityButton.backgroundColor = UIColorFromRGB(tempint);


    return cell;
}
  • 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-31T22:20:11+00:00Added an answer on May 31, 2026 at 10:20 pm

    Two problems:

    • If you are using static cells, do not implement any datasource methods in your view controller (numberOfRows, numberOfSections, cellForRow…) as this will override what you have built in the storyboard. The table has the sections, rows and content you give it in the storyboard.
    • Cells loaded from the storyboard (either dynamic prototypes, or static cells) are initialised using initWithCoder:, not initWithStyle:. awakeFromNib: is a better place to put your set up code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create my first iPhone app that would play back audio. When I
I am a cocoa newbie trying to create an iPhone app including Core Data.
I am trying to create two different sets of settings for datepicker( http://keith-wood.name/datepick.html )
I'm trying to create a nice generic way of setting the tab index on
I'm trying to create my own custom UIView for the header of a grouped
I would like to create a TRANSLUCENT grouped table view cell. In other words
I am trying to create my first own jQuery function to re-order some rows
I'm trying to scrape thesession.org to create a table of how many times each
I am trying to create a table like the one where you choose your
I'm trying to create a node form for a custom type. I have organic

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.