* 본 포스트는 Blog.MissFlash.com에서 작성한 것으로, 원문 저작자의 동의없이 마음대로 퍼가실 수 없습니다. 포스트의 내용이 마음에 드시면 링크를 이용해주시면 감사하겠습니다.
> Stanford Lecture #7
* Push to add a view controller
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
* Pop to remove a view controller
- (void)popViewControllerAnimated:(BOOL)animated;
* Pushing your first view controller
- (void)applicationDidFinishLaunching:(UIApplication *)application {
navController = [[UINavigationController alloc] init];
[navController pushViewController:firstViewController animated:NO];
[window addSubview:navController.view];
}
* Push from within a view controller on the desk
- (void)myAction:(id)sender{
UIViewController *viewController = ...;
[self.navigationController pushViewController:viewController animated:YES];
}
* Text bar button item
- (void)viewDidLoad{
UIBarButtonItem *fooButton = [[UIBarButtonItem alloc] initWithTitle:@"Foo" style:UIBarButtonItemStyleBordered target:self action:@selector(foo:)];
self.navigationItem.leftBarButtonItem = fooButton;
[fooButton release];
}
* System bar button item
- (void)viewDidLoad{
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd style:UIBarButtonItemStyleBordered target:self action:@selector(add:)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
}
* Edit/Done button
self.navigationItem.leftBarButtonItem = self.editButtonItem;
- (void)setEditing:(BOOL)editing animated:(BOOL)animated{
// Update appearance of views
}
* Custom title view
UISegmentedControl *segmentedControl = ...;
self.navigationItem.titleView = segmentedControl;
[segmentedControl release];
* Back button
self.title = @"Hello there, CS193P!";
UIBarButtonItem *heyButton = [[UIBarButtonItem alloc] initWithTitle:@"Hey!" ...];
self.navigationItem.backButtonItem = heyButton;
[heyButton release];
vs.
* Setting up a Tab Bar controller
- (void)applicationDidFinishLaunching:(UIApplication *)application {
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = myViewControllers;
[window addSubview:tabBarController.view];
}
* Creating Tab Bar items : Title and image
- (void)viewDidLoad{
self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Playlists" image:[UIImage imageNamed:@"music.png"] tag:0];
}
* Creating Tab Bar items : System item
- (void)viewDidLoad{
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:0];
}
* Nesting Navigation Controllers
- Create a Tab Bar controller
tabBarController = [[UITabBarController alloc] init];
- Create each Navigation controller
navController = [[UINavigationController alloc] init];
[navController pushViewController:firstViewController animated:NO];
- Add them to the Tab Bar controller
tabBarController.viewControllers = [NSArray arrayWithObjects:navController, anotherNavController, someViewController, nil];
'PDA&Mobile' 카테고리의 다른 글
아이폰 앱 개발 팁(8) : Stanford Lecture #9 (0) | 2010.02.12 |
---|---|
아이폰 앱 개발 팁(7) : Stanford Lecture #8 (0) | 2010.02.08 |
아이폰 앱 개발 팁(5) : Stanford Lecture #6 (0) | 2010.01.29 |
아이폰 앱 개발 팁(4) : Stanford Lectures #4-5 (0) | 2010.01.27 |
아이폰 앱 개발 팁(3) : Stanford Lecture #3 (0) | 2010.01.22 |