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!
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