我有一个应用程序,其方向锁定为纵向模式,但是当我有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];
}
希望这会帮助你。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句