显示对话框以颠倒iOS应用程序
问题描述:
我正在开发一个必须颠倒的应用程序。 我想显示一个对话框给用户,他可以接受(这会导致自动旋转)或拒绝。显示对话框以颠倒iOS应用程序
如何使用objective-c显示这样的对话框? 我需要检查info.plist中的肖像模式以及编程方式在supportedInterfaceOrientations中。对?
非常感谢您提前帮助!
答
为此使用UIAlertController。
UIAlertController * alert=[UIAlertController
alertControllerWithTitle:@"Title" message:@"Message"preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"Yes, please"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
**//What we write here????????**
NSLog(@"you pressed Yes, please button");
// call method whatever u need
}];
UIAlertAction* noButton = [UIAlertAction
actionWithTitle:@"No, thanks"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
**//What we write here????????**
NSLog(@"you pressed No, thanks button");
// call method whatever u need
}];
[alert addAction:yesButton];
[alert addAction:noButton];
[self presentViewController:alert animated:YES completion:nil];`
非常感谢您的回答。 – Johan
当然会。不幸的是我被困在旋转看[链接](https://stackoverflow.com/questions/44305964/programmatically-rotate-ios-app-upside-down-using-objective-c) – Johan