'NaviController'에 해당되는 글 1건

  1. 2010.09.13 아이폰 어플 개발할때 NaviController 빠르게 만드는 방법
아이폰어플개발정보2010. 9. 13. 09:24
아이폰 어플 개발할때 NaviController 빠르게 만드는 방법
1. window.xib에 Navigation Controller

2. View Controller 3개 

3. View Controller 3개에 각각 구별되게 Title 설정

4. 코딩
 === . h =============================================================

#import

@interface naviTestAppDelegate : NSObject {

    UIWindow *window;

IBOutletUINavigationController *navi;

IBOutletUIViewController *root;

IBOutletUIViewController *first;

IBOutletUIViewController *second;

}

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

@end

=== . m =============================================================

#import "naviTestAppDelegate.h"

@implementation naviTestAppDelegate

@synthesize window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch

root.title = @"rootview";

navi.viewControllers = [NSArrayarrayWithObject:root];

[windowaddSubview:navi.view];

    [windowmakeKeyAndVisible];

returnYES;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *cIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cIdentifier];

if(cell == nil)

{

cell = [[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cIdentifier] autorelease];

}

if(indexPath.row == 0)

cell.textLabel.text = @"first";

else

cell.textLabel.text = @"Second";

return cell;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return2;

}

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

{

if(indexPath.row == 0)

{

[navipushViewController:firstanimated:YES];

}else{

[navipushViewController:secondanimated:YES];

}

}

- (void)dealloc {

[rootrelease];

[firstrelease];

[secondrelease];

[navirelease];

    [window release];

    [super dealloc];

}

@end

5. 각각의 IBOut을 인터페이스 빌더에서 App Delegate로 연결



출처 : http://blog.naver.com/PostList.nhn?blogId=hana_815¤tPage=48
Posted by 오늘마감

댓글을 달아 주세요