0

I am trying to customize my UITableView cells and have done it successfully without problems before but that was using a storyboard. Now i am doing it using a xib file. For some reason I cannot change the cells to be "custom" cells not static. Even simple things like numberofcells methods don't work because I can't make the cells custom. Usually in a storyboard I would "delete" the cells or change them but I can't even select a cell in the nib file!enter image description here

I can't find any way to do this and using storyboards is not really an option at this point. My code is below, thanks!

#import "YouTubeViewController.h"
#import "YouTubeCell.h"

@interface YouTubeViewController ()

@end

@implementation YouTubeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return NO;
}

-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    return NO;
}

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleNone;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 88;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {


    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *reuseIdentifier = @"YouTubeCell";     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (cell == nil)
    {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"YouTubeCell" owner:nil options:nil] objectAtIndex:0];
    }

    //set up cell

    return cell;


//        [[cell authorName] setText:@"Collin Ruffenach"];
//        [[cell articleName] setText:@”Test Article 1″];
//        [[cell date] setText:@”May 5th, 2009″];
//        [[cell imageView] setImage:[UIImage imageNamed:@"1.png"]];



}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
ZB-dev
  • 219
  • 3
  • 12
  • I'm confused -- what is a "static" cell? – Hot Licks Oct 14 '14 at 03:07
  • possible duplicate of [Prototype Cells in a nib instead of a storyboard](http://stackoverflow.com/questions/8574188/prototype-cells-in-a-nib-instead-of-a-storyboard) - You can't edit prototype cells in the tableview in a nib as you can in a storyboard - you must define an additional nib and register it – Paulw11 Oct 14 '14 at 03:12
  • @Paulw11 could you elaborate on what you mean by "defining an additional nib and registering it"? – ZB-dev Oct 14 '14 at 03:34
  • Did you see the accepted answer on the question I linked to? – Paulw11 Oct 14 '14 at 03:39

1 Answers1

0

It turns out all I needed to do was set up the delegate and datasource by control clicking from the uitableview to the "files owner". Everything worked after that!

ZB-dev
  • 219
  • 3
  • 12