A classe UIAletrView permite que você exiba uma janela modal (animada) para informar e / ou pedir-lhe algo. O UIAlterView (alertas de vista) são muito confortáveis e fáceis de usar. A manipulação da resposta de utilizador é resolvido por interceptar o índice do botão pressionado. Para ver uma simples UIAlterView basta escrever:
1 2 3 4 | / / Alerta com um simples botão, sem retorno [ [ UIAlertView alloc ] initWithTitle : @ "Titolo" message : @ "Messaggio" cancelButtonTitle : @ "Annulla" otherButtonTitles : nil ] ; UIAlertView MyALERT * = [[UIAlertView alloc] initWithTitle: @ "Título" mensagem: @ "Mensagem" cancelButtonTitle: @ "Cancelar" otherButtonTitles: nil]; ; [MyALERT show]; ; [MyALERT release]; |
E 'possível adicionar botões adicionais otherButtonTitles :
1 2 3 4 | / Alerta / com dois botões simples, sem retorno [ [ UIAlertView UIAlertView MyALERT * = [[UIAlertView ; [MyALERT show]; ; [MyALERT release]; |
: Para determinar qual botão foi pressionado, basta adicionar o delegate:self objeto de inicialização UIAlterView :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Alerta / / simples com dois botões e callbacks [ [ UIAlertView alloc ] initWithTitle : @ "Titolo" message : @ "Messaggio" delegate : self cancelButtonTitle : @ "Annulla" otherButtonTitles : @ "Ok" , nil ] ; UIAlertView MyALERT * = [[UIAlertView alloc] initWithTitle: @ "Título" mensagem: @ "Mensagem" delegado: cancelButtonTitle self: @ "Cancelar" otherButtonTitles: @ "Ok", nil]; ; [MyALERT show]; ; [MyALERT release]; / / O retorno de chamada tem a seguinte sintaxe void ) alertView : ( UIAlertView * ) alertView clickedButtonAtIndex : ( NSInteger ) buttonIndex { - (Void) alertView: (UIAlertView *) clickedButtonAtIndex alertView: (NSInteger) {buttonIndex buttonIndex ) { interruptores (buttonIndex) { : case 1: / / Código quebrar; } } |
O retorno de chamada alertView precisa ter esse nome, para mais informações, consulte UIAlertViewDelegate
punteranno sempre a quella. Com apenas o callbck alertView:clickedButtonAtIndex mais UIAletrView irá sempre apontar para isso. Usando o campo de tag do objeto UIAletrView , podemos determinar o que o "chamador":
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Alerta / / simples com dois botões e callbacks [ [ UIAlertView alloc ] initWithTitle : @ "Titolo" message : @ "Messaggio" delegate : self cancelButtonTitle : @ "Annulla" otherButtonTitles : @ "Ok" , nil ] ; UIAlertView MyALERT * = [[UIAlertView alloc] initWithTitle: @ "Título" mensagem: @ "Mensagem" delegado: cancelButtonTitle self: @ "Cancelar" otherButtonTitles: @ "Ok", nil]; ; myAlertA.tag = 1; ; [MyAlertA show]; ; [MyAlertA release]; / / [ [ UIAlertView alloc ] initWithTitle : @ "Titolo" message : @ "Messaggio" delegate : self cancelButtonTitle : @ "Annulla" otherButtonTitles : @ "Ok" , nil ] ; UIAlertView myAlertB * = [[UIAlertView alloc] initWithTitle: @ "Título" mensagem: @ "Mensagem" delegado: cancelButtonTitle self: @ "Cancelar" otherButtonTitles: @ "Ok", nil]; ; myAlertA.tag = 2; ; [MyAlertB show]; ; [MyAlertB release]; / / A gestão múltipla UIAlertView void ) alertView : ( UIAlertView * ) alertView clickedButtonAtIndex : ( NSInteger ) buttonIndex { - (Void) alertView: (UIAlertView *) clickedButtonAtIndex alertView: (NSInteger) {buttonIndex "Alert Tag: %i" , alertView.tag ) ; NSLog (@ "Etiquetas de Alerta:% s", alertView.tag); "buttonIndex: %i" , buttonIndex ) ; NSLog (@ "buttonIndex:% s", buttonIndex); } |







Últimos Comentários
Rosanna : Alguém pode me dizer como faço para excluir o Snap Shots janela que se abre automaticamente quando eu ...
bendito Maresca : Eu não posso fazer download de qualquer skypemote me spiegaaa
Mateus : Olá a todos, infelizmente o Google não permite o uso da API para o Flash, mas vai ...
Giovambattista Fazioli : @ GM: Se você fazer upload de imagens para um servidor diferente (que o WordPress não pode ...
GM : Oi, desculpe ressuscitar um post antigo, mas eu espero que você possa me dar uma mão. Como eu, com este método, ...