Post a little demo I wrote a long time ago, you will understand, is the TextField set in the Alertview
@interface Viewcontroller:uiviewcontroller <uialertviewdelegate, uitextfielddelegate>{
UILabel *la;
Uitextfield *mytextfield;
}
@implementation Viewcontroller
-(void) Viewdidload
{
[Super Viewdidload];
la = [[UILabel alloc] init];
LA. Frame = CGRectMake (ten, 150,300,30);
La.backgroundcolor = [Uicolor clearcolor];
La.font = [Uifont fontwithname:@ "Helvetica-bold" size:20];
La.text = @ "Initlabel";
la.textalignment = uitextalignmentcenter;
La.shadowcolor = [Uicolor colorwithwhite:0.0f alpha:0.75f];
La.shadowoffset = Cgsizemake (0.0f, 5.0f);
La.textcolor = [Uicolor greencolor];
[Self.view Addsubview:la];
UIButton *alartbtn = [UIButton buttonwithtype:uibuttontyperoundedrect];
alartbtn.frame = CGRectMake (a);
Alartbtn.backgroundcolor = [Uicolor clearcolor];
[alartbtn settitle:@ "Alart" forstate:uicontrolstatenormal];
[alartbtn addtarget:self Action: @selector (alartshow:) forcontrolevents:uicontroleventtouchupinside];
[alartbtn setalpha:1.0];
[Self.view addsubview:alartbtn];
}
-(void) Alartshow: (ID) sender{
Uialertview *alert = [[Uialertview alloc]initwithtitle:@ "Title" message:@ "" Delegate:self cancelbuttontitle:@ "C Ancel "otherbuttontitles:@" OK ", nil];
[alert show];
[alert release];
MyTextField = [[Uitextfield alloc] Initwithframe:cgrectmake (12.0, 45.0, 260.0, 25.0)];
[MyTextField setbackgroundcolor:[uicolor whitecolor];
[alert Addsubview:mytextfield];
[MyTextField setdelegate:self];
[MyTextField addtarget:self Action: @selector (ontextfieldchanged:forevent:) forControlEvents: Uicontroleventeditingchanged];
NSLog (@ "mytextfield.text:%@", mytextfield.text);
}
-(void) Alertview: (Uialertview *) alert Clickedbuttonatindex: (Nsinteger) Buttonindex {
{
NSLog (@ "%@", mytextfield.text);
la.text = Mytextfield.text;
}
}
-(void) Alertview: (Uialertview *) alert Diddismisswithbuttonindex: (nsinteger) buttonindex{
if (Buttonindex = = [Alert Cancelbuttonindex]) {
Close (0);
}
}
-(void) ontextfieldchanged: (ID) Sender forevent: (uievent *) event{
NSLog (@ "%@", mytextfield.text);
}
picked out, probably the meaning should already have, useful oneself in look under ... Welcome technical exchanges, progress with each other. Thank you..