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 02-08-2010, 05:57 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 1
Question UINavigationController, UITabBarController, Views dont get pushed

I have posted this on some other forums, but it is allways a good idea to get second opinion :-D so here it is...
So what am i trying to achieve is to make one tab bar that switches between different views in seperate nib's. some of those views have their own navigation controllers. Interface builder nibs for main view and first view are on these pictures...

picassa album with pictures

Up until this point everything works... Tab bar switches between views, and in the first view my uitableview gets its cells and displays. Data source for uitableview is an array derived from plist that is screenshoted on 5th picture in that album.... Plist is there to emulate data source that will be some database, but at this point all i need is few data records so i use plist..
the idea behind all these stuff is to show root category in first uitableview and on selected row it detects if that row has any children and creates same uiviewcontroller but with different data source (this time with children of selected element) if it doesnt have children then shows detail view, and pushes it to view controller...
In idea this is all looks pretty well but in practice i have pretty big problem...
root view is displayed as you can see in 6th picture and when i select any row, view gets pushed to subcategory or children view, but when i select row in that view nothing happens...
In console i can se that view properly detects datasource, and existence of child elements, but is rejects to push view...
Ill post my FirstViewController.m file so maybe someone will have an idea why is this happening.

Code:
#import "FirstViewController.h"
#import "SingleViewController.h"
#import "CrotuneDemoAppDelegate.h"
#import "CellView.h"


@implementation FirstViewController

@synthesize tableDataSource,CurrentTitle,CurrentLevel,navigationController,reklama,mreklama,stringMreklama,stringReklama;



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	//
	
	if (CurrentLevel==0) {
		//start datasource
		NSArray *tempArray = [[NSArray alloc] init];
		self.tableDataSource=tempArray;
		[tempArray release];
		
		CrotuneDemoAppDelegate *AppDelegate = (CrotuneDemoAppDelegate *)[[UIApplication sharedApplication] delegate];
		self.tableDataSource = [AppDelegate.data objectForKey:@"Rows"];
		
		self.navigationItem.title = @"Categories";
		
		[mreklama setImage:[UIImage imageNamed:@"mkras.jpg"]];
		[reklama setImage:[UIImage imageNamed:@"kras.jpg"]];
		
	}
	else{
		
		self.navigationItem.title = CurrentTitle;
		[mreklama setImage:[UIImage imageNamed:stringMreklama]];
		[reklama setImage:[UIImage imageNamed:stringReklama]];
		
	}
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDelay:1];
	[UIView setAnimationDuration:1];
	[reklama setAlpha:0];
	[UIView commitAnimations];
		//NSLog(@"%@",tableDataSource);

}


	//table delegate metods

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

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
	static NSString *CellIdentifier = @"CellView";

	
	CellView *cell = (CellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (cell == nil){
		
		NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CellView" owner:nil options:nil];
		
		
		for(id currentObject in topLevelObjects)
		{
			if([currentObject isKindOfClass:[CellView class]])
			{
				cell = (CellView *)currentObject;
				break;
			}
		}
		
	}
		// Set up the cell...
	NSDictionary *dictionary =[self.tableDataSource objectAtIndex:indexPath.row];
	
	[[cell title] setText:[dictionary objectForKey:@"Title"]];
	[[cell background] setImage:[UIImage imageNamed:[dictionary objectForKey:@"Image"]]];
	
	return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	
	
		//Get the dictionary of the selected data source.
	NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
	
		//Get the children of the present item.
	NSArray *Children = [dictionary objectForKey:@"Children"];
	
	if([Children count] == 0) {
		SingleViewController *detailView =[[SingleViewController alloc] initWithNibName:@"SingleView" bundle:[NSBundle mainBundle]];
		
			//ovdje dodaj objekt sa podatcima od pojedinog subjekta
		[self.navigationController pushViewController:detailView animated:YES];
		[detailView release];
	
	}
	else {
		
			//Prepare to tableview.
	
		FirstViewController *nextView = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];
		
			//Increment the Current View
		nextView.CurrentLevel += 1;
		
			//Set the title;
		nextView.CurrentTitle = [dictionary objectForKey:@"Title"];
		
		nextView.stringMreklama=[dictionary objectForKey:@"SAdd"];
		nextView.stringReklama=[dictionary objectForKey:@"LAdd"];
		
		nextView.tableDataSource = Children;
		
			//Push the new table view on the stack
		[self.navigationController pushViewController:nextView animated:YES];
		
		
		[nextView release];
		
		[tableView deselectRowAtIndexPath:indexPath animated:YES];
	}
}


- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
I have been banging my head up against the wall for last 12 hours and i cant help myself so ill politely ask for your help...
Thanks in advance...
kviksilver is offline   Reply With Quote
Old 10-29-2010, 08:30 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 28
Default How to create uinavigationcontroller in secon page?

Hi,

Am new to iphone I need uinavigationcontroller to start from second page.ie.,
SQLite Tutorial - Updating data - iPhone SDK Articles

The app in the above link must start from second page after clickin the button from first page.Am trying to get this from last 4 days.Without this I cannot move my project forward.If any one gets this, mail me to smrafiqsmd@gmail.com


Thank u
rafiq is offline   Reply With Quote
Old 10-29-2010, 09:51 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 327
Default

I'm just quickly looking at this, but self.navigationController doesn't make sense to me if you're trying to push the view onto the root view controller. It would work the first time you select a row because you're referencing the correct navigation controller, but after that wouldn't you not be referencing the correct one?
thomashw is offline   Reply With Quote
Old 12-07-2010, 05:05 AM   #4 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 28
Default Am not getting

Am not getting that I have tried what all the ways i have known.Can u do it.am trying from one month.

Thank u
rafiq is offline   Reply With Quote
Reply

Bookmarks

Tags
uinavigationcontroller, uitabbarcontroller, uiview

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: 276
26 members and 250 guests
ADY, Bertrand21, Dani77, Dattee, fkmtc, HDshot, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, jimbo, macquitzon216, MACralik, mer10, NSeven, prchn4christ, Rudy, sacha1996, silverwiz, sneaky, spiderguy84, Sunny46, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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