首页 > 移动平台 > 详细

IOS起航 UI初级 窗体跳转 代理传值

时间:2015-06-06 00:13:11      阅读:375      评论:0      收藏:0      [点我收藏+]
技术分享
//
//  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

 

IOS起航 UI初级 窗体跳转 代理传值

原文:http://www.cnblogs.com/MacKun/p/4555798.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!