Swift 2.0:
Использовать AlertController.
Пример для листа действий:
let mediaActionSheet: UIAlertController = UIAlertController(title: "Media Action Sheet", message: "Choose an option!", preferredStyle: .ActionSheet)
//Create and add the Cancel action
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
//Just dismiss the action sheet
}
mediaActionSheet.addAction(cancelAction)
//Create and add first option action
let takePictureAction: UIAlertAction = UIAlertAction(title: "Take Picture", style: .Default) { action -> Void in
//Code for launching the camera goes here
}
mediaActionSheet.addAction(takePictureAction)
//Create and add a second option action
let choosePictureAction: UIAlertAction = UIAlertAction(title: "Choose From Gallery", style: .Default) { action -> Void in
//Code for picking from gallery goes here
}
mediaActionSheet.addAction(choosePictureAction)
//Present the AlertController
self.presentViewController(mediaActionSheet, animated: true, completion: nil)
Пример для предупреждений:
1)
let simpleAlert = UIAlertController(title: "Simple Alert", message: "It is just awesome", preferredStyle: UIAlertControllerStyle.Alert);
//show it
showViewController(simpleAlert, sender: self);
2) Уведомление с TextField в нем.
let inputTextFieldAlert:UIAlertController = UIAlertController(title: " Input TextField Alert ", message: " Enter on the below TextField ", preferredStyle: UIAlertControllerStyle.Alert);
//default input textField (no configuration...)
inputTextFieldAlert.addTextFieldWithConfigurationHandler(nil);
//no event handler (just close dialog box)
inputTextFieldAlert.addAction(UIAlertAction(title: "No", style: UIAlertActionStyle.Cancel, handler: nil));
//event handler with closure
inputTextFieldAlert.addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.Default, handler: {(action:UIAlertAction) in
let fields = inputTextFieldAlert.textFields!;
print("Output: "+fields[0].text!);
}));
presentViewController(inputTextFieldAlert, animated: true, completion: nil);
3)
var alert = UIAlertController(title: "TextField Alert", message: "Enter on the below TextField", preferredStyle: UIAlertControllerStyle.Alert);
//configured input textField
var field:UITextField?;
alert.addTextFieldWithConfigurationHandler({(input:UITextField)in
input.placeholder="Empty Dtaa ;-)";
input.clearButtonMode=UITextFieldViewMode.WhileEditing;
field=input;
});
//YES Handler
func yesHandler(actionTarget: UIAlertAction){
print(field!.text!);
}
//event handler with predefined function
alert.addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.Default, handler: yesHandler));
presentViewController(alert, animated: true, completion: nil);
Эта проблема также может быть результатом применения унаследованных стилей к содержимому информационного окна после того, как оно было прикреплено к карте.
Например: размер шрифта будет рассчитываться на основе шрифта по умолчанию. Когда информационное окно прикреплено, шрифт изменится на основе унаследованного CSS и, если он больше, будет выходить за нижнюю часть информационного окна.
Если вы не хотите удалять унаследованный стиль (и в большинстве случаев вы этого не сделаете), вам необходимо явно отменить унаследованный стиль в содержимом информационного окна.
Вы можете найти отличное описание этой проблемы и ее решение по адресу:
Если InfoWindow содержит изображение, оно может быть переполнено, потому что размер InfoWindow устанавливается перед загрузкой изображения. В этом случае вам нужно указать размер изображения или предварительно загрузить его.
В противном случае я бы просто поместил содержимое в div с полосой прокрутки:
div.infowindow {
max-height:250px;
overflow-y:auto;
}