//
// ViewController.m
// viewControllerTrans
//
// Created by 徐坤坤 on 15/6/5.
// Copyright (c) 2015年 hr. All rights reserved.
//
#import "ViewController.h"
#import "textBoxView.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(50, 50, 80, 80)];
label.text=@"Welcome to China";
label.textColor=[UIColor redColor];
[label setTextAlignment:NSTextAlignmentCenter];
UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(80, 100, 100, 120)];
[btn setTitle:@"Hello" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(changeView:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:label];
[self.view addSubview:btn];
// Do any additional setup after loading the view, typically from a nib.
}
-(void) changeView:(UIButton *)btn
{
NSLog(@"Welcome!");
textBoxView *tbView=[[textBoxView alloc]init];
[self presentModalViewController:tbView animated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// textBoxView.m
// viewControllerTrans
//
// Created by 徐坤坤 on 15/6/5.
// Copyright (c) 2015年 hr. All rights reserved.
//
#import "textBoxView.h"
@interface textBoxView ()
{
UITextField *txt;
}
@end
@implementation textBoxView
- (void)viewDidLoad {
[super viewDidLoad];
txt=[[UITextField alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
txt.textColor=[UIColor redColor];
txt.text=@"IOS";
UIButton *btn=[[UIButton alloc]initWithFrame:CGRectMake(50, 120, 100,140)];
[btn addTarget:self action:@selector(showMessage:) forControlEvents:UIControlEventTouchUpInside];
[btn setTitle:@"OK" forState:(UIControlStateNormal)];
[self.view addSubview:btn];
[self.view addSubview:txt];
// Do any additional setup after loading the view.
}
- (void)setValue:(NSString *)value
{
}
-(void)showMessage:(UIButton *)btn
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示"
message:txt.text
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
NSLog(@"alert");
[alert show];
//[alert release];
// txt.text;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end