I tried to be descriptive in title, but there is not enough room to explain all of my problems :-(
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...
uinavigationcontroller album
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.
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...
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...
uinavigationcontroller album
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:
//
// FirstViewController.m
// CrotuneDemo
//
// Created by Boris Erceg on 2/4/10.
// Copyright Apple Inc 2010. All rights reserved.
//
#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...