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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 10-22-2008, 01:31 PM   #1 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 36
Default Nesting a TableView in a NavigationView in A TabBarView

I am having a horrible time trying to get this to work.

I've implemented the table in iPhone Noobs 'Click a Cell' guide and am now trying to figure out how I can get that working within a Tab Bar.

From what I've read, it looks like I need to nest a Navigation Controller within a Tab Bar Controller. Is this right?

Everything works great, except when I try to click a cell, I get an ugly error:

Quote:
[Session started at 2008-10-22 13:21:05 -0400.]
2008-10-22 13:21:05.622 test234[20029:20b] *** -[NSCFArray objectForKey:]: unrecognized selector sent to instance 0x44cdf0
2008-10-22 13:21:05.623 test234[20029:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray objectForKey:]: unrecognized selector sent to instance 0x44cdf0'
2008-10-22 13:21:05.624 test234[20029:20b] Stack: (
2473791819,
2488942139,
2473821002,
2473814348,
2473814546,
28501,
816648952,
816663775,
816672452,
816674377,
816673653,
9639,
816434578,
816463537,
816274443,
816209415,
816206378,
829003042,
829012108,
2473293333,
2473295096,
829005112,
829005309,
816175835,
816221412,
8196
)
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found).
warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory).
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/kevinowocki/Library/Application Support/iPhone Simulator/User/Applications/3C89B470-CF49-48B7-82B1-A01A9FBDB74D/test234.app/test234', process 20029.
Here is my code for pushing the detailed view when a cell in my table is clicked :

Quote:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


// load the clicked cell
FirstViewImageCell *cell = (FirstViewImageCell *)[tableView cellForRowAtIndexPath:indexPath];

// init the controller
FirstDetailViewController *controller = [[FirstDetailViewController alloc] initWithNibName:@"FirstDetailView" bundle:nil];

// set the ID and call JSON in the controller
[controller setID:[cell getID]];

// show the view
[[self navigationController] pushViewController:controller animated:YES];
// [self.tabBarController selectedViewController]

}
Here is the hierarchy of my Controllers, via IB:



Any thoughts? You'll be my best friend if you can help out!

Thanks!
marioluig is offline   Reply With Quote
Old 10-22-2008, 01:41 PM   #2 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 75
Default

in order for me to get that working.. i had to setup a tabbar in code.. in iB mine is just a blank tabbar

then i set things up in code like the following

Code:
	NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:5];
	
	self.detailsController= [[PostDetailsViewController alloc] initWithNibName:@"PostDetailsView" bundle:nil];
	self.detailsController.title = @"Details";
	self.detailsController.tabBarItem.image = [UIImage imageNamed:@"write.png"];
	self.detailsController.postController = self;
	[array addObject:self.detailsController];
	
	self.photoController = [[PostPhotosViewController alloc] initWithNibName:@"PostPhotosView" bundle:nil];
	self.photoController.title = @"Photos";
	self.photoController.tabBarItem.image = [UIImage imageNamed:@"photos.png"];
	self.photoController.postController = self;
	
	[array addObject:self.photoController];
	
	tabController.viewControllers = array;
	self.view = tabController.view;
	
	tabController.delegate = nil;
	tabController.selectedIndex = 1;
	tabController.selectedIndex = 0;
	tabController.delegate = self;
	
	[array release];
__________________
Iphone Noob iPhone Development Blog. Learn to develop for the iPhone SDK with me
hijinks is offline   Reply With Quote
Old 10-22-2008, 01:58 PM   #3 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 36
Default

Really? Any thoughts on why you can do it in code, but not in IB?

I'm really hoping to use IB to create this functionality. The entire project is built around the interface in IB, so I'd rather not reorganize just for this.
marioluig is offline   Reply With Quote
Old 10-22-2008, 02:28 PM   #4 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 361
Default

Have a look at TabBarController - Navigation Controller - TableView thread and I have dealt with it completely.

There are rather simple ways to do this actually, even in IB.

In IB, just create your table View controller class. Add a navigationcontroller to MainWindow. Drop the ViewController in the Navigation Controller. Now: add a Tab Bar Controller (easier just to use the original TabBar app base), open it, and drag the navigation controller into the TAB BAR AT THE BOTTOM of view Controller. A new icon will pop up, and you will have created it. It doesn't quite work like other view controllers, its actually much simpler.
DevTeamOfOne is offline   Reply With Quote
Old 10-22-2008, 02:50 PM   #5 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 36
Default

Quote:
Originally Posted by DevTeamOfOne View Post
Have a look at TabBarController - Navigation Controller - TableView thread and I have dealt with it completely.

There are rather simple ways to do this actually, even in IB.

In IB, just create your table View controller class. Add a navigationcontroller to MainWindow. Drop the ViewController in the Navigation Controller. Now: add a Tab Bar Controller (easier just to use the original TabBar app base), open it, and drag the navigation controller into the TAB BAR AT THE BOTTOM of view Controller. A new icon will pop up, and you will have created it. It doesn't quite work like other view controllers, its actually much simpler.
I'm sorry. To be honest, I'm not following you. Especially that last paragraph. I understand how to use IB to nest the TableViewController inside the NavigationController inside the TabBarController.

What I can't figure out is why I am greeted with a nasty stack trace (see OP) whenever I click on a cell inside of that nested TableView.
marioluig is offline   Reply With Quote
Old 10-22-2008, 03:12 PM   #6 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
Default

Couple suggestions: Which line in your code is causing this run time exception? Step through the code and find that out.

The runtime exception is telling you that somewhere an array is being called like a dictionary.

Code:
[NSCFArray objectForKey:]: unrecognized selector sent to instance 0x44cdf0'
Some code is sending objectForKey, an NSDictionary method, to a NSCFArray object.

When you figure out which line that's happening on you can figure out why.
PhoneyDeveloper is offline   Reply With Quote
Old 10-22-2008, 03:24 PM   #7 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 36
Default

Quote:
Originally Posted by PhoneyDeveloper View Post
Couple suggestions: Which line in your code is causing this run time exception? Step through the code and find that out.
...

When you figure out which line that's happening on you can figure out why.


Thanks for your response... It's happening on this line:

Code:
// show the view
[[self navigationController] pushViewController:controller animated:YES];
marioluig is offline   Reply With Quote
Old 10-22-2008, 03:33 PM   #8 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 36
Default

Quote:
Originally Posted by PhoneyDeveloper View Post
Some code is sending objectForKey, an NSDictionary method, to a NSCFArray object.
It was the 'viewDidLoad' method in the view I was calling. Thanks for converting that 'console speak' to plain English. I never would have considered looking there if it weren't for that.

DevTeamofOne, PhoneyDeveloper, and hijinks, thanks so much for your help!
marioluig is offline   Reply With Quote
Old 10-22-2008, 05:32 PM   #9 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
Default

One more thing, look at my comments about gdbinit in the below thread. You can set a breakpoint so that your code breaks when the runtime exception is going to be thrown and you can look at the stack and see exactly what line of your code is causing the failure.

http://www.iphonedevsdk.com/forum/ip...problem-2.html
PhoneyDeveloper is offline   Reply With Quote
Reply

Bookmarks

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: 458
13 members and 445 guests
banatary70, darbsllim, DaveDee, Domele, dre, EdwardMichel, HowEver, ilmman, iOSguru, johnRambo, maryrobertson, Objective Zero, Oral B
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 157,853
Threads: 88,914
Posts: 379,297
Top Poster: BrianSlick (7,072)
Welcome to our newest member, banatary70
Powered by vBadvanced CMPS v3.1.0

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