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];