The problem of forward transfer in IOS development

Source: Internet
Author: User

Two input boxes and one button

    _textfiled = [[Uitextfield alloc]init];
    _textfiled.frame = CGRectMake (0, 100, 320, 50);
    _textfiled.textcolor = [Uicolor Redcolor];
    _textfiled.borderstyle = Uitextborderstyleroundedrect;
    _textfiled.font = [Uifont boldsystemfontofsize:20];
    _textfiled.delegate = self;
    _textfiled.tag = 1000;
    
    [Self.view addsubview:_textfiled];
    _textfiled1 = [[Uitextfield alloc]init];
    _textfiled1.frame = CGRectMake (0, 300, 320, 50);
    _textfiled1.textcolor = [Uicolor Redcolor];
    _textfiled1.borderstyle = Uitextborderstyleroundedrect;
    _textfiled1.font = [Uifont boldsystemfontofsize:20];
    _textfiled1.delegate = self;
    _textfiled1.securetextentry = YES;
    _textfiled1.tag = 2000;
    
    [Self.view addsubview:_textfiled1];
    _button = [UIButton buttonwithtype:uibuttontypecustom];
    _button.frame = CGRectMake (320/2, 360, 100, 50);
    UIImage * Image_button = [uiimage imagenamed:@ "9.gif"]; [_button addtarget:self Action: @selector (Buttonaction) Forcontrolevents:uicontroleventtouchupinside];
    
    [_button Setimage:image_button Forstate:uicontrolstatenormal];
    [_button Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; [Self.view Addsubview:_button];

Method of passing values

-(void) buttonaction{
    
    //forward-transmitted value
    Uitextfield * textField1 = (Uitextfield *) [Self.view viewwithtag:1000];
    Uitextfield * TextField2 = (Uitextfield *) [Self.view viewwithtag:2000];
    
    Viewcontroller_text * Text = [[Viewcontroller_text alloc]init];
    Text.text1 = Textfield1.text;
    Text.text2 = Textfield2.text;
    
    Switch to the next interface
    [self presentviewcontroller:text animated:yes completion:nil];

}

Get the value in the next interface:

Uilabel * label = [[Uilabel alloc]initwithframe:cgrectmake (M, 310,)];
    Label.textalignment = Nstextalignmentleft;
   The value passed down from the previous interface
    label.text = [NSString stringwithformat:@ "text1:%@-----text2:%@", _text1,_text2];
    Label.textcolor = [Uicolor redcolor];
    [Label Setfont:[uifont Boldsystemfontofsize:20]];
    Label.backgroundcolor = [Uicolor graycolor];
    [Self.view Addsubview:label];




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.