显示对话框以倒转 iOS 应用程序
Show dialog to rotate iOS app upside down
我正在开发一个必须颠倒的应用程序。
我想向用户显示一个对话框,他可以接受(这将导致自动轮换)或拒绝。
如何使用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];`
我正在开发一个必须颠倒的应用程序。 我想向用户显示一个对话框,他可以接受(这将导致自动轮换)或拒绝。
如何使用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];`