0

Trying to set the bounds of my table view to be smaller than my screen. I am setting it in my viewDidLoad method but nothing happens when I run. Not sure why it's not working. Am I calling it in the right place??

 //OptionsViewController.m

 - (void)viewDidLoad
 {
     [super viewDidLoad];
     self.tableView.frame = CGRectMake(1,1,29,80);
 }

 //  OptionsViewController.h
 #import <UIKit/UIKit.h>

 @interface OptionsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
 {
     NSIndexPath *selectedRowIndex;
 }

 @property (weak, nonatomic) NSIndexPath *selectedRowIndex;
 @property (weak, nonatomic) IBOutlet UITableView *tableView;

 @end
mablecable
  • 385
  • 1
  • 6
  • 15
  • are you also taking table view in story board?? if so then delete the tableview from storyboard and give it the bounds programatically like you are doing in viewDidLoad. I am just asking because you have taken IBOutlet of tableView, and if you are creating tableView dynamically you do not need to use IBOutlet. – Kaushal Bisht Feb 04 '13 at 07:34

1 Answers1

0

Set the frame in viewDidAppear method . It works. You might want to look at the following question and answer for a good explanation :

Unable to set frame correctly before viewDidAppear

TL;DR - The UI elements are not drawn to screen yet during viewDidLoad .

Community
  • 1
  • 1
Samhan Salahuddin
  • 2,140
  • 1
  • 17
  • 24