Ir para conteúdo
  • Cadastre-se

TextField dentro de AlertViews?


Posts Recomendados

Já vi que é possível, e já consegui aplicar, mas não consigo utilizar o valor digitado no TextField do AlertView...

Bom, aí está o código, pra quem quiser ver:

- (IBAction)buttonPressed:(id)sender{
	UIAlertView *alert = [[[UIAlertView alloc]initWithTitle:@"Enter password"
													message:@" "
												    delegate:self
												    cancelButtonTitle:@"Add"
													otherButtonTitles:@"Cancel",nil]autorelease];

	UITextField *tagField = [[[UITextField alloc]

	initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)]
                            autorelease];

	// tagField.

	tagField.backgroundColor = [UIColor whiteColor];

	tagField.tag = 10;
	tagField.keyboardType = UIKeyboardTypeAlphabet;
        tagField.secureTextEntry = YES;


	[alert show];

	[alert addSubview:tagField];


	/*if (tagField.text = "Un1v3rs0") {
		lockView.hidden = NO;
		unlockView.hidden = YES;
	}
	 */
}	


- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
	//the add button
	UITextField *tagName = (UITextField*)[alertView viewWithTag:10];
	if(buttonIndex == 0) {
		if(tagName.text != nil) {
			// do some tag adding
		}
	}
	[tagName removeFromSuperview];
}

Obrigado pela atenção!

Editado por Gabriel Vincent
Link para o comentário
Compartilhar em outros sites

  • Respostas 0
  • Criado
  • Última resposta

Top Postadores Neste Tópico

Dias Populares

Top Postadores Neste Tópico

Dias Populares

Participe do debate

Você pode postar agora e se registrar depois. Se você tem uma conta, entre agora para postar com ela.

Visitante
Responder este tópico…

×   Você colou conteúdo com formatação.   Remover formatação

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Limpar editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.



  • Estatísticas do Fórum

    • Total de Tópicos
      56.2k
    • Total de Posts
      465.6k
×
×
  • Criar Novo...