'navigationcontroller'에 해당되는 글 1

  1. 2011.06.28 NavigationController 에다가 TableView붙이기
2011. 6. 28. 10:48 카테고리 없음

프로젝트는 windowbased로 만들어서 xib에서는 아무 작업도하지 않고 했습니다 .
레퍼런스 예제를 참고해서 다짤라내고 뼈대만 있는것입니다.


@implementation
testsimpleAppDelegate


@synthesize window,navi;





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

    

    // Override point for customization after application launch.

    RootView *root =[[RootView alloc]initWithStyle:UITableViewStylePlain];

    navi= [[UINavigationController alloc] initWithRootViewController:root];


    [self.window addSubview:navi.view];

    [self.window makeKeyAndVisible];

   

    [root release];

    return YES;

}





#import <UIKit/UIKit.h>


@interface testsimpleAppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;

UINavigationController *navi;

}

@property (nonatomic,retain)UINavigationController *navi;

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


 



#import "RootView.h"



@implementation RootView

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

{


}


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

{

static NSString *cIdentifier=@"cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cIdentifier];

if(cell == nil)

{

cell= [[[UITableViewCell alloc]

initWithStyle:UITableViewCellStyleDefault            reuseIdentifier:cIdentifier]autorelease];

}

if(indexPath.row == 0)

cell.textLabel.text=@"첫번째 줄입니다.";

else 

cell.textLabel.text=@"두번째 줄입니다.";

return cell;

}

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

{

return 2;

}

- (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 {

    [super viewDidUnload];

    // Release any retained subviews of the main view.

    // e.g. self.myOutlet = nil;

}



- (void)dealloc {

    [super dealloc];

}



@end


#import <UIKit/UIKit.h>



@interface RootView : UITableViewController {


}


@end

 

 

posted by 욱이다
prev 1 next