【发布时间】:2014-10-21 10:36:40
【问题描述】:
我正在开发的应用只支持纵向模式。但是,在 iOS8 中,现已弃用的 UIAlertView 可以进入横向并显示其他一些小问题。为了解决这个问题,我决定试试UIAlertController。它有效,但我有一个新问题,仍然有点烦人。警报不再进入风景,但它确实具有视差运动的东西。我在UIAlertController 的视图中添加了一个标签和一个图像,但它们没有视差,这意味着当用户移动手机时它看起来很奇怪。
我正在寻找两个选项,但我找不到其中任何一个的方法。
第一个解决方案是禁用视差,看看我们在应用程序的任何地方都不支持它。
第二种解决方案是为标签和图像添加视差支持。
无论如何,这是一段代码:
UIAlertController *welcomeAlertController = [UIAlertController
alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Would you like to send %@ a message?", @"This message is displayed after adding a new message receiver. The %@ is the name of the receiver."), self.receiver.name]
message:@"\n\n\n\n\n\n\n\n"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Skip", @"Skip: meaning user can skip a certain step.")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
[self cancelButtonPressed];
}];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Send", @"Send: meaning user can send information to somewhere.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
[self sendButtonClicked];
}];
[welcomeAlertController addAction:cancelAction];
[welcomeAlertController addAction:okAction];
smsView.frame = CGRectMake(20, 80, 240, 95);
messageBackgroundView.frame = CGRectMake(0, 0, 240, 80);
warningLabel.frame = CGRectMake(20, 170, 240, 40);
warningLabel.textColor = [UIColor blackColor];
[welcomeAlertController.view addSubview:smsView]; // An UIView
[welcomeAlertController.view addSubview:warningLabel];
[self presentViewController:welcomeAlertController animated:YES completion:nil];
【问题讨论】:
-
Reddit post,过了几天没有回复,所以让他在这里发帖。
-
我计划在宽限期内将赏金奖励给当前接受的答案,除非有人知道如何关闭视差。
标签: ios ios8 parallax uialertcontroller