我试图从一个导航观察控制员(DateViewController)提出一个模式。
我在“InfoContoller”的意见上添加了一个工具。 现在我想在工具栏上添加一个标题“Info”和“Done”纽扣。 多纽纽纽州将采用信息促进发展的行动方法。
谁能给我 so? 感谢很多!
页: 1
#import <UIKit/UIKit.h>
#import "InfoViewController.h"
@interface DateViewController : UIViewController
{
InfoViewController *infoViewController;
}
@property (nonatomic, retain) InfoViewController *infoViewController;
@end
DateViewController.m
- (IBAction)modalViewAction:(id)sender{
if (self.infoViewController == nil)
self.infoViewController = [[[InfoViewController alloc] initWithNibName:
NSStringFromClass([InfoViewController class]) bundle:nil] autorelease];
[self presentModalViewController:self.infoViewController animated:YES];
}
- (void)dealloc{
if (self.infoViewController != nil)
{
[infoViewController release];
}
[super dealloc];
}
- (void)viewDidLoad{
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Info" style:UIBarButtonSystemItemPlay target:self action:@selector(modalViewAction:)] autorelease];
[modalBarButtonItem release];
[super viewDidLoad];
}
Here s InfoViewController.m
- (IBAction)infoDismissAction:(id)sender{
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
- (void)viewDidLoad {
UIToolbar *toolBar;
toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
toolBar.frame = CGRectMake(0, 0, 320, 50);
toolBar.barStyle = UIBarStyleDefault;
[toolBar sizeToFit];
[self.view addSubview:toolBar];
[toolBar release];
[backButton release];
[super viewDidLoad];
}