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 08-05-2010, 01:09 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 4
Terry is on a distinguished road
Default UIView & UIWebView in UINavigationController

Hello people,

i have UINavigationController as root which develop in Window-based, i need to have a skeleton as below:
First level is UITableView
Second level also UITableView
Third level is UIView //problem on third level
Fourth level is UIWebView //not yet implement

AppDelegate.h
Code:
#import <UIKit/UIKit.h>

@interface ForkerAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
	UINavigationController *navController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navController;
@end
AppDelegate.m
Code:
#import "ForkerAppDelegate.h"

@implementation ForkerAppDelegate
@synthesize window;
@synthesize navController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    // Override point for customization after application launch
	[window addSubview: navController.view];
    [window makeKeyAndVisible];
	//return YES;
}
- (void)dealloc {
	[navController release];
    [window release];
    [super dealloc];
}
@end
FirstLevelController.h /*first level is an UITableViewController
Code:
#import <Foundation/Foundation.h>

@interface FirstLevelController : UITableViewController {
	NSArray *controllers;
}
@property (nonatomic, retain) NSArray *controllers;
@end
FirstLevelController.m
Code:
#import "FirstLevelController.h"
#import "DisclosureButtonController.h"

@implementation FirstLevelController
@synthesize controllers; 

- (void)viewDidLoad {
	self.title = @"First Level";
	NSMutableArray *array = [[NSMutableArray alloc] init]; 
        //DisclosureButton
	self.controllers = array; 
	[array release]; 
	[super viewDidLoad];
} 
- (void)viewDidUnload {
	self.controllers = nil; 
	[super viewDidUnload];
} 
- (void)dealloc {
	[controllers release]; 
	[super dealloc];
}
#pragma mark - 
#pragma mark Table Data Source Methods

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
	static NSString *FirstLevelCell= @"FirstLevelCell"; 
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: FirstLevelCell];
	if (cell == nil) { 
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
									   reuseIdentifier: FirstLevelCell] autorelease];
	} // Configure the cell 
	NSUInteger row = [indexPath row]; 
	SecondLevelViewController *controller = [controllers objectAtIndex:row]; 
	cell.textLabel.text = controller.title; 
	//cell.imageView.image = controller.rowImage; 
	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
	return cell;
} 

#pragma mark - 
#pragma mark Table View Delegate Methods 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	NSUInteger row = [indexPath row]; 
	SecondLevelViewController *nextController = [self.controllers objectAtIndex:row];
	[self.navigationController pushViewController:nextController
										 animated:YES];
}
@end
SecondLevelViewController.h //second level also UITableView
Code:
#import <Foundation/Foundation.h>

@interface SecondLevelViewController : UITableViewController {
	NSArray *controllers;
}
@property (nonatomic, retain) NSArray *controllers;
@end
SecondLevelViewController.m
Code:
#import "SecondLevelViewController.h"
#import "ThirdLevelController.h"
#import "DetailView.h"

@implementation SecondLevelViewController 
@synthesize controllers;

@end
ThirdLevelController.h //Third level is UIView
Code:
#import <Foundation/Foundation.h>
@interface ThirdLevelController : UIViewController {
}

@end
ThirdLevelController.m
Code:
#import "ThirdLevelController.h"
@implementation ThirdLevelController
@end
DisclosureButtonController.h //this is for secondlevelviewcontroller
Code:
#import <Foundation/Foundation.h>
#import "SecondLevelViewController.h"

@interface DisclosureButtonController : SecondLevelViewController {
	NSArray *list;
}
@property (nonatomic, retain) NSArray *list;
@end
DisclosureButtonController.m
Code:
#import "DisclosureButtonController.h"
#import "ForkerAppDelegate.h"
#import "ThirdLevelController.h"

@implementation DisclosureButtonController
@synthesize list; 

- (void)viewDidLoad {
    //my list array 
}
- (void)viewDidUnload {
	self.list = nil; 
} 
- (void)dealloc {
	[list release]; 
	[super dealloc];
}	
#pragma mark -
#pragma mark Table Data Source Methods 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
	return[list count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	static NSString * DisclosureButtonCellIdentifier = @"DisclosureButtonCellIdentifier";
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: DisclosureButtonCellIdentifier];
	if (cell == nil) { 
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
									   reuseIdentifier: DisclosureButtonCellIdentifier] autorelease];
	} 
	NSUInteger row = [indexPath row]; 
	NSString *rowString =[list objectAtIndex:row]; 
	cell.textLabel.text = rowString;
	cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
	[rowString release]; 
	return cell;
}
#pragma mark - 
#pragma mark Table View Delegate Methods 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	NSUInteger row = [indexPath row]; 
	ThirdLevelController *nextController = [self.controllers objectAtIndex:row];
	[self.navigationController pushViewController:nextController
										 animated:YES];
}
@end
DetailView.h //this is for thirdlevelcontroller
Code:
@interface DetailView : ThirdLevelController {
	IBOutlet UIButton *button;
}
@property (nonatomic, retain) IBOutlet UIButton *button;
- (IBAction)buttonPressed:(id)sender;
@end
DetailView.m
Code:
#import "DetailView.h"
#import "ForkerAppDelegate.h"

@implementation DetailView
@synthesize button;

- (IBAction) buttonPressed:(id)sender {
	//go url
}
- (void)viewWillAppear:(BOOL)animated {
	[super viewWillAppear:animated];
}
- (void)viewDidUnload {
	[super viewDidUnload];
}
- (void)dealloc {
	[super dealloc];
}
@end
In MainWindow.xib, i drag an Navigation Controller to its MainWindow.xib window, and change the First Level Controller (Root View Controller) class as FirstLevelController.

then, I've also created a new DetailView.xib, what i've done on the DetailView.xib is click on its File's Owner and changed its class to DetailView, then i control-drag to View icon, and select view.

Problem: i build and run, there are no warning and error message. And in the simulator, i tap on first level, is going to second level, which is fine, when i tap the content on second level table, it terminate.
This problem bothering me for several sleepless days, hope you guys can help up. Appreciate it. Thanks

Regards
Terry

Last edited by Terry; 08-05-2010 at 01:19 AM. Reason: Detail explanation
Terry is offline   Reply With Quote
Old 08-05-2010, 07:44 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 4
Terry is on a distinguished road
Default

anyone ?
Terry 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: 322
10 members and 312 guests
alexP, arash5500, gordo26, mediaspree, nobstudio, Objective Zero, rayjeong, Sloshmonster, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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