servidor saliente puedo mail funciona error enviar correos correo configurar conectar con aplicacion ios objective-c cocoa-touch uiview

ios - saliente - Creación de un menú emergente de iPhone similar al menú de la aplicación de correo



error al conectar con el servidor saliente smtp.gmail.com iphone (7)

Creando una Hoja de Acción en Swift

Código actualizado para Swift 3

Desde iOS 8, se UIAlertController combinado con UIAlertControllerStyle.ActionSheet . UIActionSheet está en desuso.

Aquí está el código para producir la Hoja de Acción en la imagen de arriba:

class ViewController: UIViewController { @IBOutlet weak var showActionSheetButton: UIButton! @IBAction func showActionSheetButtonTapped(sender: UIButton) { // Create the action sheet let myActionSheet = UIAlertController(title: "Color", message: "What color would you like?", preferredStyle: UIAlertControllerStyle.actionSheet) // blue action button let blueAction = UIAlertAction(title: "Blue", style: UIAlertActionStyle.default) { (action) in print("Blue action button tapped") } // red action button let redAction = UIAlertAction(title: "Red", style: UIAlertActionStyle.default) { (action) in print("Red action button tapped") } // yellow action button let yellowAction = UIAlertAction(title: "Yellow", style: UIAlertActionStyle.default) { (action) in print("Yellow action button tapped") } // cancel action button let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel) { (action) in print("Cancel action button tapped") } // add action buttons to action sheet myActionSheet.addAction(blueAction) myActionSheet.addAction(redAction) myActionSheet.addAction(yellowAction) myActionSheet.addAction(cancelAction) // support iPads (popover view) myActionSheet.popoverPresentationController?.sourceView = self.showActionSheetButton myActionSheet.popoverPresentationController?.sourceRect = self.showActionSheetButton.bounds // present the action sheet self.present(myActionSheet, animated: true, completion: nil) } }

¿Aún necesitas ayuda? Mira este video tutorial. Así lo aprendí.

Me gustaría crear un menú emergente similar al que se encuentra en la aplicación de correo cuando desea responder a un mensaje. He visto esto en más de una aplicación, así que no estaba seguro de si había algo incorporado en el marco o algún código de ejemplo.


A todos los que buscan una solución en Swift:

  1. Adoptar el protocolo UIActionSheetDelegate

  2. Crea y muestra el ActinSheet:

    let sheet: UIActionSheet = UIActionSheet() sheet.addButtonWithTitle("button 1") sheet.addButtonWithTitle("button 2") sheet.addButtonWithTitle("button 3") sheet.addButtonWithTitle("Cancel") sheet.cancelButtonIndex = sheet.numberOfButtons - 1 sheet.delegate = self sheet.showInView(self.view)

  3. La función de delegado:

    func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){ switch buttonIndex{ case 0: NSLog("button1"); case 1: NSLog("button2"); case 2: NSLog("button3"); case actionSheet.cancelButtonIndex: NSLog("cancel"); break; default: NSLog("blub"); break; } }


Así es como lo harías en Objective-C en iOS 8+:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Directions" message:@"Select mode of transportation:" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *drivingAction = [UIAlertAction actionWithTitle:@"Driving" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { // this block runs when the driving option is selected }]; UIAlertAction *walkingAction = [UIAlertAction actionWithTitle:@"Walking" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { // this block runs when the walking option is selected }]; UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; [alert addAction:drivingAction]; [alert addAction:walkingAction]; [alert addAction:defaultAction]; [self presentViewController:alert animated:YES completion:nil];



Intenté agregar ActionSheet en mi vista. Así que he estado tratando de encontrar la solución perfecta, pero algunas respuestas me confundieron. Debido a que la mayoría de las preguntas sobre la hoja de acción fueron escritas hace mucho tiempo. Tampoco se ha actualizado. De todos modos ... escribiré la versión anterior de ActionSheet y la versión actualizada de ActionSheet. Espero que mi respuesta sea capaz de hacer pacífico tu cerebro.

----------Versión actualizada---------

UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"Action Sheet" message:@"writeMessageOrsetAsNil" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction* actionSheet01 = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { NSLog(@"OK click");}]; UIAlertAction* actionSheet02 = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {NSLog(@"OK click");}]; UIAlertAction* actionSheet03 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { NSLog(@"Cancel click");}]; [browserAlertController addAction:actionSheet01]; [browserAlertController addAction:actionSheet02]; [browserAlertController addAction:actionSheet03]; [self presentViewController:browserAlertController animated:YES completion:nil];

-------Versión antigua------

UIActionSheet *actionSheet= [[UIActionSheet alloc] initWithTitle:@"Select Sharing option:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@“OK”, @“NO”,@“Cancel”, nil]; actionSheet.tag = 100; [actionSheet showInView:self.view]; - (void)actionSheet:(UIActionSheet *)actionShee clickedButtonAtIndex:(NSInteger)buttonIndex { if( actionSheet.tag == 100){ switch (buttonIndex) { case 0: [self doSomething]; break; case 1: [self doAnything]; break; case 2: [self doNothing]; break; default: break; } break; } }


Necesitas usar una UIActionSheet.

Primero debe agregar UIActionSheetDelegate a su archivo ViewController .h.

Luego puedes hacer referencia a una hoja de acción con:

UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select Sharing option:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Share on Facebook", @"Share on Twitter", @"Share via E-mail", @"Save to Camera Roll", @"Rate this App", nil]; popup.tag = 1; [popup showInView:self.view];

Entonces tienes que manejar cada una de las llamadas.

- (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex { switch (popup.tag) { case 1: { switch (buttonIndex) { case 0: [self FBShare]; break; case 1: [self TwitterShare]; break; case 2: [self emailContent]; break; case 3: [self saveContent]; break; case 4: [self rateAppYes]; break; default: break; } break; } default: break; } }

Esto ha sido desaprobado a partir de iOS 8.x.

https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UIAlertController_class/index.html


Vea el ejemplo de UICatalog en el sitio web de Apple. La sección "Alertas" tiene ejemplos de cómo usar UIActionSheet para lograr lo que estás tratando de hacer.