#import "MainViewController.h"
#import "SecondViewController.h"
@interface MainViewController ()
@property(nonatomic,retain)UITextField *textfield;
@end
@implementation MainViewController
-(void)dealloc
{
[_textfield release];
[super dealloc];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor cyanColor];
UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(200, 100, 100, 40);
[button setTitle:@"下一页" forState:UIControlStateNormal];
button.layer.borderWidth=1;
button.layer.cornerRadius=10;
[self.view addSubview:button];
[button addTarget:self action:@selector(click:) forControlEvents:
UIControlEventTouchUpInside];
UIView *view =[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.backgroundColor=[UIColor blackColor];
[self.view addSubview:view];
[view release];
self.navigationController.navigationBar.translucent=NO;
self.navigationItem.title=@"鹰王电影";
UISegmentedControl *seg=[[UISegmentedControl alloc] initWithItems:@[@"信息",@"通话"]];
self.navigationItem.titleView=seg;
self.navigationItem.leftBarButtonItem=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(leftButtonAction:)] autorelease];
UIButton *rightButton=[UIButton buttonWithType:UIButtonTypeCustom];
rightButton.frame=CGRectMake(0, 0, 40, 40);
[rightButton setImage:[UIImage imageNamed:@"天平.png"] forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.textfield=[[UITextField alloc] initWithFrame:CGRectMake(100, 200, 100, 40)];
self.textfield.layer.borderWidth=1;
self.textfield.layer.cornerRadius=10;
[self.view addSubview:self.textfield];
[self.textfield release];
}
-(void)leftButtonAction:(UIBarButtonItem *)button
{
}
-(void)right:(UIBarButtonItem *)button
{
}
-(void)click:(UIButton *)button
{
SecondViewController *secVC=[[SecondViewController alloc] init];
secVC.number=100;
secVC.str=self.textfield.text;
secVC.arr=@[@"杨林",@"刘山山"];
[self.navigationController pushViewController:secVC animated:YES];
[secVC release];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@property(nonatomic,assign)NSInteger number;
@property(nonatomic,copy)NSString *str;
@property(nonatomic,retain)NSArray *arr;
@end
#import "SecondViewController.h"
#import "ThirdViewController.h"
@interface SecondViewController ()
@property(nonatomic,retain)UILabel *label;
@end
@implementation SecondViewController
-(void)dealloc
{
[_label release];
[super dealloc];
[_arr release];
[_str release];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor orangeColor];
UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(200, 100, 100, 40);
[button setTitle:@"下一页" forState:UIControlStateNormal];
button.layer.borderWidth=1;
button.layer.cornerRadius=10;
[self.view addSubview:button];
[button addTarget:self action:@selector(click:) forControlEvents:
UIControlEventTouchUpInside];
NSLog(@"%ld",self.number);
self.label=[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 50, 40)];
self.label.backgroundColor=[UIColor redColor];
[self.view addSubview:self.label];
[self.label release];
self.label.text=self.str;
NSLog(@"%@",self.arr[0]);
}
-(void)click:(UIButton *)button
{
ThirdViewController *thirdVC=[[ThirdViewController alloc] init];
[self.navigationController pushViewController:thirdVC animated:YES];
[thirdVC release];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
#import "ThirdViewController.h"
@interface ThirdViewController ()
@end
@implementation ThirdViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor yellowColor];
UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];
button.frame=CGRectMake(200, 100, 100, 40);
[button setTitle:@"返回" forState:UIControlStateNormal];
button.layer.borderWidth=1;
button.layer.cornerRadius=10;
[self.view addSubview:button];
[button addTarget:self action:@selector(click:) forControlEvents:
UIControlEventTouchUpInside];
}
-(void)click:(UIButton *)button
{
[self.navigationController popToRootViewControllerAnimated:YES ];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end