Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-18-2011, 05:13 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 7
oleger is on a distinguished road
Default Custom cells not working

Hi, I have a table view with custom cells build using this tutorial : The Pragmatic Studio | Bonus Track

And now I have 2 issues.

First and main, nothing happens when I tap on a row, I mean its highlighted but not opening new view

Second: How can I make these custom cells to open individual views displaying text and button to listen to audio. And is it possible that my existing tab bar will be still visible?

Thank you






This is my table.h
Code:
@class ChapterTableCell;


@interface AllChaptersTableViewController : UITableViewController {
    NSArray *chapters;
    IBOutlet ChapterTableCell *chapterTableCell;
}

@property (nonatomic, retain) NSArray *chapters;
@property (nonatomic, retain) ChapterTableCell *chapterTableCell;


@end




and this is my table.m file

Code:
#import "AllChaptersTableViewController.h"
#import "AllChaptersTableViewController.h"
#import "speaking_palAppDelegate.h"
#import "Chapter.h"
#import "ChapterTableCell.h"

@implementation AllChaptersTableViewController


@synthesize chapters, chapterTableCell;

- (void)viewDidLoad {
	self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg.jpg"]];


	
    self.title = @"Chapters";
    
    Chapter *one = [[Chapter alloc] 
					initWithName:@"1" 

					  imageName:@"Button_1.png"];
    
    Chapter *two = [[Chapter alloc] 
					initWithName:@"2" 
					 imageName:@"Button_2.png"];
    

	Chapter *three = [[Chapter alloc] 
					  initWithName:@"3" 
					imageName:@"Button_3.png"];
	
	Chapter *four = [[Chapter alloc] 
					 initWithName:@"4" 
					imageName:@"Button_4.png"];
    
	Chapter *five = [[Chapter alloc] 
					 initWithName:@"5" 
					 imageName:@"Button_5.png"];
	
	Chapter *six = [[Chapter alloc] 
					initWithName:@"6" 
					 imageName:@"Button_6.png"];
	
	Chapter *seven = [[Chapter alloc] 
					  initWithName:@"7" 
					 imageName:@"Button_7.png"];
	
	Chapter *eight = [[Chapter alloc] 
					  initWithName:@"8" 
					 imageName:@"Button_8.png"];
	
	Chapter *nine = [[Chapter alloc] 
					 initWithName:@"9" 
					 imageName:@"Button_9.png"];
	
	Chapter *ten = [[Chapter alloc] 
					initWithName:@"10" 
					 imageName:@"Button_10.png"];
	
	Chapter *eleven = [[Chapter alloc] 
					   initWithName:@"11" 
					 imageName:@"Button_11.png"];
	
	Chapter *twelve = [[Chapter alloc] 
					   initWithName:@"12" 
					 imageName:@"Button_12.png"];
	
	Chapter *thirteen = [[Chapter alloc] 
						 initWithName:@"13" 
					 imageName:@"Button_13.png"];
	
	Chapter *fourteen = [[Chapter alloc] 
						 initWithName:@"14" 
					 imageName:@"Button_14.png"];
	
	Chapter *fifteen = [[Chapter alloc] 
						initWithName:@"15" 
					 imageName:@"Button_15.png"];
	
	Chapter *sixteen = [[Chapter alloc] 
						initWithName:@"16" 
					 imageName:@"Button_16.png"];
	
	Chapter *seventeen = [[Chapter alloc]
						  initWithName:@"17" 
						  imageName:@"Button_17.png"];
	
	
    NSArray *exampleData = 
		[[NSArray alloc] initWithObjects:one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, nil];
    self.chapters = exampleData;
    [one release];
    [two release];
    [three release];
    [four release];
	 [five release];
	 [six release];
	 [seven release];
	 [eight release];
	 [nine release];
	 [ten release];
	 [eleven release];
	 [twelve release];
	 [thirteen release];
	 [fourteen release];
	 [fifteen release];
	 [sixteen release];
	 [seventeen release];
	
	
    [exampleData release];
    
    [super viewDidLoad];
}

#pragma mark -
#pragma mark Memory methods

- (void)dealloc {
    [chapters release];
    [chapterTableCell release];
    [super dealloc];
}

#pragma mark -
#pragma mark Table View methods

- (NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section {
    return [self.chapters count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView 
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"ChapterCellId";
    
    ChapterTableCell *cell = 
	(ChapterTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"ChapterTableCell" owner:self options:nil];
        cell = chapterTableCell; 
	}
	
    Chapter *chapter = [chapters objectAtIndex:indexPath.row];
		cell.imageView.image = [UIImage imageNamed:[chapter imageName]];
		
    return cell;
}
	
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 73;
}	






- (NSIndexPath *)tableView:(UITableView *)tableView 
willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	return nil;
}



@end

and this is cell.m
Code:
#import "ChapterTableCell.h"
#import "Chapter.h"


@implementation ChapterTableCell


@synthesize nameLabel, imageView;



- (void)dealloc {
    [nameLabel release];
    [imageView release];
    [super dealloc];
}

@end

and cell h

Code:
@interface ChapterTableCell : UITableViewCell {

    IBOutlet UILabel *nameLabel;
    IBOutlet UIImageView *imageView;
}

@property (nonatomic, retain) UILabel *nameLabel;
@property (nonatomic, retain) UIImageView *imageView;


@end

Last edited by oleger; 07-18-2011 at 05:49 AM. Reason: code
oleger is offline   Reply With Quote
Old 07-18-2011, 08:06 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 39
phoney is on a distinguished road
Default

Quote:
Originally Posted by oleger View Post
Hi, I have a table view with custom cells build using this tutorial : The Pragmatic Studio | Bonus Track

And now I have 2 issues.

First and main, nothing happens when I tap on a row, I mean its highlighted but not opening new view

Second: How can I make these custom cells to open individual views displaying text and button to listen to audio. And is it possible that my existing tab bar will be still visible?

Thank you






This is my table.h
Code:
@class ChapterTableCell;


@interface AllChaptersTableViewController : UITableViewController {
    NSArray *chapters;
    IBOutlet ChapterTableCell *chapterTableCell;
}

@property (nonatomic, retain) NSArray *chapters;
@property (nonatomic, retain) ChapterTableCell *chapterTableCell;


@end




and this is my table.m file

Code:
#import "AllChaptersTableViewController.h"
#import "AllChaptersTableViewController.h"
#import "speaking_palAppDelegate.h"
#import "Chapter.h"
#import "ChapterTableCell.h"

@implementation AllChaptersTableViewController


@synthesize chapters, chapterTableCell;

- (void)viewDidLoad {
	self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg.jpg"]];


	
    self.title = @"Chapters";
    
    Chapter *one = [[Chapter alloc] 
					initWithName:@"1" 

					  imageName:@"Button_1.png"];
    
    Chapter *two = [[Chapter alloc] 
					initWithName:@"2" 
					 imageName:@"Button_2.png"];
    

	Chapter *three = [[Chapter alloc] 
					  initWithName:@"3" 
					imageName:@"Button_3.png"];
	
	Chapter *four = [[Chapter alloc] 
					 initWithName:@"4" 
					imageName:@"Button_4.png"];
    
	Chapter *five = [[Chapter alloc] 
					 initWithName:@"5" 
					 imageName:@"Button_5.png"];
	
	Chapter *six = [[Chapter alloc] 
					initWithName:@"6" 
					 imageName:@"Button_6.png"];
	
	Chapter *seven = [[Chapter alloc] 
					  initWithName:@"7" 
					 imageName:@"Button_7.png"];
	
	Chapter *eight = [[Chapter alloc] 
					  initWithName:@"8" 
					 imageName:@"Button_8.png"];
	
	Chapter *nine = [[Chapter alloc] 
					 initWithName:@"9" 
					 imageName:@"Button_9.png"];
	
	Chapter *ten = [[Chapter alloc] 
					initWithName:@"10" 
					 imageName:@"Button_10.png"];
	
	Chapter *eleven = [[Chapter alloc] 
					   initWithName:@"11" 
					 imageName:@"Button_11.png"];
	
	Chapter *twelve = [[Chapter alloc] 
					   initWithName:@"12" 
					 imageName:@"Button_12.png"];
	
	Chapter *thirteen = [[Chapter alloc] 
						 initWithName:@"13" 
					 imageName:@"Button_13.png"];
	
	Chapter *fourteen = [[Chapter alloc] 
						 initWithName:@"14" 
					 imageName:@"Button_14.png"];
	
	Chapter *fifteen = [[Chapter alloc] 
						initWithName:@"15" 
					 imageName:@"Button_15.png"];
	
	Chapter *sixteen = [[Chapter alloc] 
						initWithName:@"16" 
					 imageName:@"Button_16.png"];
	
	Chapter *seventeen = [[Chapter alloc]
						  initWithName:@"17" 
						  imageName:@"Button_17.png"];
	
	
    NSArray *exampleData = 
		[[NSArray alloc] initWithObjects:one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, nil];
    self.chapters = exampleData;
    [one release];
    [two release];
    [three release];
    [four release];
	 [five release];
	 [six release];
	 [seven release];
	 [eight release];
	 [nine release];
	 [ten release];
	 [eleven release];
	 [twelve release];
	 [thirteen release];
	 [fourteen release];
	 [fifteen release];
	 [sixteen release];
	 [seventeen release];
	
	
    [exampleData release];
    
    [super viewDidLoad];
}

#pragma mark -
#pragma mark Memory methods

- (void)dealloc {
    [chapters release];
    [chapterTableCell release];
    [super dealloc];
}

#pragma mark -
#pragma mark Table View methods

- (NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section {
    return [self.chapters count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView 
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"ChapterCellId";
    
    ChapterTableCell *cell = 
	(ChapterTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"ChapterTableCell" owner:self options:nil];
        cell = chapterTableCell; 
	}
	
    Chapter *chapter = [chapters objectAtIndex:indexPath.row];
		cell.imageView.image = [UIImage imageNamed:[chapter imageName]];
		
    return cell;
}
	
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 73;
}	






- (NSIndexPath *)tableView:(UITableView *)tableView 
willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	return nil;
}



@end

and this is cell.m
Code:
#import "ChapterTableCell.h"
#import "Chapter.h"


@implementation ChapterTableCell


@synthesize nameLabel, imageView;



- (void)dealloc {
    [nameLabel release];
    [imageView release];
    [super dealloc];
}

@end

and cell h

Code:
@interface ChapterTableCell : UITableViewCell {

    IBOutlet UILabel *nameLabel;
    IBOutlet UIImageView *imageView;
}

@property (nonatomic, retain) UILabel *nameLabel;
@property (nonatomic, retain) UIImageView *imageView;


@end
u can use didSelectRowAtIndexPath method......then u can write navigation logic in in that method
phoney is offline   Reply With Quote
Reply

Bookmarks

Tags
custom cells, tab bar based app, table view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 412
15 members and 397 guests
blasterbr, buggen, Clouds, dre, EvilElf, HemiMG, jeroenkeij, jimmyon122, jonathandeknudt, LEARN2MAKE, Mah6447, n00b, nyoe, pungs, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,668
Threads: 94,121
Posts: 402,901
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jonathandeknudt
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:56 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0