objective c - UIAlertView with textField -


i experiment @ moment alertviews. try set alertview 2 textfield`s. when click "done" should show log.

at moment, code looks that:

    uialertview *alert = [[uialertview alloc] initwithtitle:@"titel" message:@"message" delegate:self cancelbuttontitle:@"done" otherbuttontitles:@"cancel", nil]; 

the textfield should have placeholder. how set up?

try this: should work:

 uialertview *av = [[uialertview alloc] initwithtitle:@"your_title" message:@"your_message" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles:@"ok", nil]; [av setalertviewstyle:uialertviewstyleloginandpasswordinput];  // alert style customization  [[av textfieldatindex:1] setsecuretextentry:no]; [[av textfieldatindex:0] setplaceholder:@"first_placeholder"]; [[av textfieldatindex:1] setplaceholder:@"second_placeholder"]; [av show]; 

you can access values of text fields on alertview:clickedbuttonatindex: of uialertviewdelegate.

-(void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex{      nslog(@"1 %@", [alertview textfieldatindex:0].text);      nslog(@"2 %@", [alertview textfieldatindex:1].text); } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -