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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:11:06+00:00 2026-06-15T02:11:06+00:00

Rather than bloat and convolute this post with what I’ve tried and failed at,

  • 0

Rather than bloat and convolute this post with what I’ve tried and failed at, I’ll just keep it simple, as I’m sure the answer is probably simpler than I think.

I have a scrolling UITableView on the main view of my application. All I’m trying to do is move the default position–or “starting point”–of the scrolling UITableView down about 194 points to make room for my navigation bar and a couple other UI elements. How do I do this? Here are what I believe to be the pertinent method implementations from my ViewController .h and .m files, respectively:

//     MGViewController.h
//     UITVPractice

#import <Foundation/Foundation.h>

@interface ItemsViewController : UITableViewController

-(id) init;
-(id) initWithStyle:(UITableViewStyle)style;

@end



//     MGViewController.m
//     UITVPractice

#import "ItemsViewController.h"
#import "MGItem.h"
#import "MGItemStore.h"

@implementation ItemsViewController

-(void)viewDidLoad {
    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
    self.tableView.backgroundView = backgroundImageView;

    [super viewDidLoad];
}

-(id) init {
    self = [super initWithStyle:UITableViewStyleGrouped];

    if (self) {
        /* create 5 random MGItems and place in the MGItemStore */
        for (int i = 0; i < 20; i++) {
            [[MGItemStore sharedStore] createItem];
        }
    }
    return self;
}

-(NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    return [[[MGItemStore sharedStore] allItems] count];
}

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];

    /* Create an instance of UITableViewCell */
    if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                                   reuseIdentifier:@"UITableViewCell"];
    }

    UIView *backView = [[UIView alloc] initWithFrame:CGRectZero];
    backView.backgroundColor = [UIColor clearColor];
    cell.backgroundView = backView;

    /* Display custom background image for cell(s) */
    cell.backgroundView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"cellBackground.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]];

    /* Display custom background image for selected cell(s) */
    cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"cellBackgroundTouched.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]];

    /* eliminate the white box that bounds the black text.  */
    [[cell contentView] setBackgroundColor:[UIColor clearColor]];
    [[cell backgroundView] setBackgroundColor:[UIColor clearColor]];
    [cell setBackgroundColor:[UIColor clearColor]];

    /* Set the text of the cell to the description of the item that is at the nth index of items, where n = row this cell will appear in on the tableView */
    MGItem *p = [[[MGItemStore sharedStore] allItems] objectAtIndex:[indexPath row]];
    [[cell textLabel] setText:[p description]];
    [[cell textLabel] setTextColor:[UIColor whiteColor]];
//    [[cell textLabel] highlightedTextColor: [UIColor purpleColor]];

    return cell;
}

-(id) initWithStyle:(UITableViewStyle)style {
    return [self init];
}

@end

I apologize if this post comes off as a “do this for me” post, but I’ve tried about a dozen different things and none of them have worked. Been stuck on this for about 3 days. Thanks for any help you can provide.

EDIT: Yes, Ismael, you’re correct. It is a subclass of UITableViewController. I think I understand what you’re saying. Working on it now. Thanks to both who answered.

  • 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-15T02:11:08+00:00Added an answer on June 15, 2026 at 2:11 am

    I take it your controller is a subclass of UITableViewController? If that’s the case, then you will have to change that.

    In order to do this, change the subclass to UIViewController, add the UITableViewDelegate and UITableViewDataSource protocols.

    Then, add a UITableView *tableView property and change your viewDidLoad method to look like this:

    -(void)viewDidLoad {
        [super viewDidLoad]; // [super viewDidLoad]; should go first!!
    
        CGFloat startingPoint = 194.0; // or whatever
        CGRect tableRect = self.view.bounds;
        tableRect.origin.y = startingPoint;
        tableRect.size.height -= startingPoint;
    
        self.tableView = [[UITableView alloc] initWithFrame:tableRect style:UITableViewStyleGrouped]; // or plain, whichever you need
        self.tableView.dataSource = self;
        self.tableView.delegate = self;
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; // do this if grouped, looks better!
        self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.view addSubview:self.tableView];
    
        UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
        self.tableView.backgroundView = backgroundImageView;
    
    }
    

    Edit: There’s a reason for this. In a normal UIViewController, the self.view is a UIView, but in a UITableViewController, the self.view is the same as self.tableView and is a UITableView, and that’s why you can’t change the frame of it.

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

Sidebar

Related Questions

Rather than attempt this in words, I'll just give an example: I have an
Rather than just grabbing the user's friends' emails, I want to show their list
Rather than scraping a Ruby version of this algorithm off the net I wanted
Rather than just writing a new function called import() i'd like to know if
this is more of an algorithmic question rather than a specific language question, so
Really simple question but rather than asking for an academic explanation I want to
rather than use something like yepnope.js is there a simple method/decent plugin that can
Consider this as a challenge rather than its general approach. The reason I mention
This is more of a general question rather than a specific problem. I'm coding
Rather than M-x zone-when-idle <RET> 30 i'd like this to be the default. What

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.