Я использую AlertView с момента выпуска iOS8, но после выпуска iOS8 UIAlertView заменяет UIAlertViewController. Затем, как использовать его как UIAlertView.Как использовать UIAlertView с iOS 8?
-1
A
ответ
1
AlertView в Swift в ios8
var alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
0
if ([UIAlertController class])
{
// use UIAlertController
UIAlertController *alert= [UIAlertController
alertControllerWithTitle:@"Enter Folder Name"
message:@"Keep it short and sweet"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action){
//Do Some action here
}];
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
NSLog(@"cancel btn");
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:ok];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];
использовать этот код
+0
этот полезный. – technerd
1
UIAlertController * myAlert= [UIAlertController
alertControllerWithTitle:@"My Alert"
message:@"put a message here"
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:MyAlert animated:YES completion:nil];
Привет и добро пожаловать к переполнению стека. можете ли вы дать нам немного больше информации? Также, пожалуйста, отредактируйте свой вопрос и добавьте код, который вы пытались заставить его работать, и объясните, какая у вас была ошибка (укажите любые соответствующие записи в журнале, если у вас есть). Также расскажите, какие исследования вы сделали по этому вопросу (поэтому мы не дублируем ваши усилия). Спасибо –
http://nshipster.com/uialertcontroller/ –
http://stackoverflow.com/questions/25111011/uialertview-uialertcontroller-ios-7-and-ios-8-compatibility –