Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-26-2009, 12:35 PM   #1 (permalink)
gunther
Registered Member
 
Join Date: Jun 2009
Posts: 196
Default UInavigation + tabbar.. help

Hi, i read in this forum in other tread over this issue but not find the answer rigth.. so.. any can help me?

i have a application what handle a tab bar whit 5 buttons and one button=1view, this works fine.. this views have a data array to input to tableview.. this works fine.. but the problem is when i touch a row in tableview, this action will send me to other view whit data detail.. and this not happend. this the code.

delegate.h
#import <UIKit/UIKit.h>

@class negociosViewController;

@interface iPublicarAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
negociosViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) negociosViewController *viewController;

@end

---------------

delegate.m
#import "delegateAppDelegate.h"
#import "categoriasViewController.h"
#import "negociosViewController.h"
#import "sitiosViewController.h"
#import "favoritosViewController.h"
#import "randomViewController.h"

@implementation delegateAppDelegate
@synthesize window, viewController;

- (void)applicationDidFinishLaunching (UIApplication *)application {

UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];
[window addSubview:navController.view];

tabBarController = [[UITabBarController alloc] init];

categoriasViewController *catViewController = [[categoriasViewController alloc] initWithNibName:@"categoriasView" bundle:nil];
catViewController.title = @"Categorias";

negociosViewController *negViewController = [[negociosViewController alloc] initWithNibName:@"negociosView" bundle:nil];
negViewController.title = @"Negocios";

sitiosViewController *sitViewController = [[sitiosViewController alloc] initWithNibName:@"sitiosView" bundle:nil];
sitViewController.title = @"Sitios";

favoritosViewController *favViewController = [[favoritosViewController alloc] initWithNibName:@"favoritosView" bundle:nil];
favViewController.title = @"Favoritos";

randomViewController *ranViewController = [[randomViewController alloc] initWithNibName:@"randomView" bundle:nil];
ranViewController.title = @"Random";

tabBarController.viewControllers = [NSArray arrayWithObjects:catViewController, negViewController, sitViewController, favViewController, ranViewController, nil];

[catViewController release];
[negViewController release];
[sitViewController release];
[favViewController release];
[ranViewController release];

[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}

- (void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
}

@end

VIEW WHIT TABLEVIEW

categorias.h
#import <UIKit/UIKit.h>
@interface categoriasViewController : UIViewController {
IBOutlet UITableView *tblSimpleTable;
NSArray *arryData;
}
@end

categorias.m
#import "categoriasViewController.h"
#import "nextCatViewController.h"

@implementation categoriasViewController

- (void)viewDidLoad {
arryData = [[NSArray alloc] initWithObjects:@"iPhone",@"iPod",@"MacBook",@"Mac Book Pro",nil];
[super viewDidLoad];
}

- (NSInteger)numberOfSectionsInTableView (UITableView *)tableView {
return 1;
}


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


// Customize the number of rows in the table view.
- (NSInteger)tableView (UITableView *)tableView numberOfRowsInSection(NSInteger)section {
return [arryData count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
UIImage *image = [UIImage imageNamed:@"icon.png"];
cell.image = image;
cell.text = [arryData objectAtIndex:indexPath.row];
return cell;
}

- (void)tableView (UITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {
nextCatViewController *nextController = [[nextCatViewController alloc] initWithNibName:@"nextCatView" bundle:nil];
[self.navigationController pushViewController:nextController animated:YES];
[nextController changeProductText:[arryData objectAtIndex:indexPath.row]];
}

@end

VIEW DETAIL DATA -> NAVIGATION ACTION

.h
#import <UIKit/UIKit.h>
@interface nextCatViewController : UIViewController {
IBOutlet UILabel *lblProductTxt;
}

- (IBAction) changeProductTextNSString *)str;
@end

.m
#import "nextCatViewController.h"


@implementation nextCatViewController

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

- (IBAction) changeProductText (NSString *)str{
lblProductTxt.text = str;
}

@end

THANKS FOR HELP.
gunther is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,326
Threads: 39,123
Posts: 171,541
Top Poster: smasher (2,577)
Welcome to our newest member, danuff
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.