我有一个应用程序,其方向被锁定为纵向模式,但是当我有 UIAlertView 并将 iPhone 转到横向模式时,警报会更改方向并裁剪警报的叠加层。仅在 iOS8 中。
有人遇到过这个错误吗?
是的,我确实遇到了这个问题。我已经在 iOS7 中开发了代码,但也必须与 iOS 8 兼容。所以我遇到了这个链接。我得到的解决方案如下:
当您使用 iOS7 时,UIAlertView 工作正常,但如果您使用 iOS8,则必须使用 UIAlertController。使用这种代码:
if(SYSTEM_VERSION_LESS_THAN(@"8.0"))
{
alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Invalid Coupon." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
else
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Warning" message:@"Invalid Coupon." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"OK action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
希望对你有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)