Tag: uialertview

本地化系统生成的隐私警报消息iOS UIAlertView Xcode

我有一个使用Xcode Swift 1.1开发的应用程序,并使用iOS 7.1和iOS 8.1模拟器进行testing。 该应用程序允许用户访问他们的照片库,但在他们之前,iOS显示隐私警报消息标题要求用户的英语语言权限 – “ 应用程序名称 ”将访问您的照片。 (注意:调用PHAsset和/或ALAssetsLibrary时会触发警报。) 我的应用程序将以几种不同的语言提供,例如中文。 不过,无论何时我尝试本地化或testing不同的语言设置,上述隐私警报消息总是以英文显示。 我希望系统隐私警报消息以在用户设备上设置的语言显示。 我已经在Xcode中尝试了许多不同的位置设置和本地化语言,在模拟器中没有区别。 我应该期望(或者很容易)在真实设备上设置不同的位置,iOS会自动为所有系统生成的隐私警报消息显示正确的语言吗? 本地化系统隐私警报消息时,我缺less什么? (注意:我无法在真实设备上进行testing,并且在Info.plist中设置“隐私 – 图片库使用说明”键不会更改隐私警报消息标题,而是会为警报设置可选说明。)

直接从支持iOS8 +的iOS应用redirect到通知设置

我的要求是,如果应用程序的通知被用户closures,用户在那个时候打开应用程序,它会给应用程序打开通知警报,当点击警报视图应用程序的OKbutton将redirect到通知屏幕用户需要点击开关button才能打开通知。 是否有可能在ios8 +? 我想redirect这个屏幕 谢谢

UIAlertView上面的UIView

在我的应用程序中,使用locking屏幕。 有时会显示UIAlertView ,现在当用户将应用程序发送到后台并将其重新放在前面时, UIAlertview会显示在locking屏幕上方。 是否有可能添加一个UIViewController的视图高于一切,即上面的UIAlertView ?

简单的UIAlertView与NSAttributedString(s)

我正在寻找一个简单的方法来使用一个非常简单的消息框类似于NSAttributedString : NSString *new_item = [NSString stringWithFormat:@"<span style=\"font-family: Helvetica Neue; font-size: 12.0\">%@</span>", @"MOTD HTML String downloaded from website"]; NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[new_item dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MOTD" message:attrStr delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; 我上面的代码需要一个HTML格式的string,已经从服务器上下载,确保文本大小适合屏幕,然后尝试将NSAttributedString发送到UIAlertView 。 但是UIAlertView不喜欢这个。 这个问题最简单的方法是什么?(非HTML格式的MOTD不是一个选项)

如何在swift中在UIAlertView中添加UITableView

如何在UIAlertView中dynamic添加UITableView。 将UIAlertView的子视图添加到UITableView后,不显示。 override func viewDidLoad() { super.viewDidLoad() tableView.frame = CGRectMake(0, 50, 320, 200); tableView.delegate = self tableView.dataSource = self tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") } @IBAction func textFieldCliked(sender: AnyObject) { alertView.message = "table view" alertView.addButtonWithTitle("Ok") alertView.addSubview(tableView) alertView.show() }

检查运行的代码是否是unit testing用例

我想检查运行的代码是否是unit testing的情况,或者是否对结果执行不同的代码,例如: if ( unit test case is running ) { do something } else { do other thing } 任何想法呢?

UIActivityIndi​​catorView在UIAlertView上不能正确显示

我正在写一个iOS应用程序,我必须显示一个微调UIAlertView。 有时候 ,当我试图将微调器添加到警戒中心的时候,通常是在这之前有另一个警报(不是一个规则,但是这是我注意到它失败了)的时候出了点问题。 我通过延迟微调创build来部分解决了这个错误。 这是我怎么做( 警报是一个成员UIAlertView): 这段代码在viewDidLoad中: alert = [[[UIAlertView alloc] initWithTitle:@"Loading…" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles: nil] autorelease]; [alert show]; [self performSelector:@selector(addSpinner) withObject:nil afterDelay:0.5f]; 而这个是我的addSpinner函数: – (void) addSpinner{ UIActivityIndicatorView *indicator2 = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; indicator2.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height – 50); [indicator2 startAnimating]; [alert addSubview:indicator2]; [indicator2 release]; } 这个解决scheme每次都在工作,但我真的不喜欢它是如何完成的。 即使在警报popup后半秒钟显示微调,也不会太令人不安,所以必须有更好的方法来处理这个问题。 我不是iOS的专家,也不是高级程序员,但我不能使用事件吗? 像“什么时候实际显示警报,去addSpinnerfunction”? 我不知道如何做到这一点,并没有findnetworking上的帮助… 希望可以有人帮帮我 […]

如何在Swift中显示popup消息3秒钟后消失或者立即可以被用户取消?

在我的swift应用程序,我有一个单一的buttonUIViewController。 这个button调用一个函数,调用3秒钟后消失的popup窗口。 此外,在那之后,它将打印一条消息给控制台。 这个函数的代码如下: func showAlertMsg(title: String, message: String){ let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert) self.presentViewController(alertController, animated: true, completion: nil) let delay = 3.0 * Double(NSEC_PER_SEC) let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) dispatch_after(time, dispatch_get_main_queue(), { alertController.dismissViewControllerAnimated(true, completion: nil) print("popup disappeared") }) } 这工作正常,但我想介绍一些改进。 我想添加一个button,将立即取消这个popup,然后避免在控制台显示消息。 有没有办法向用户显示这样的popup窗口? 另外 – 是否有方法显示在这个popup消息的计数器秒数运行,显示多less时间,直到popup消失?

UIDatePicker自定义

我已经定制了UIDatePicker到一个级别,我将它添加到UIAlertView。 但是我在dateselect器的底部和顶部获得了一个黑色,如何删除它。 我希望dateselect器整洁干净。 我用来实现这个的代码: UIDatePicker *datePicker = [[UIDatePicker alloc] init]; datePicker.frame=CGRectMake(20, 45.0, 240.0, 150.0); datePicker.minimumDate=[NSDate date]; //Forget about this logic. NSString *alertTitleString=@""; if(self.presentingViewController !=nil) { alertTitleString=@"Select Date and Time"; [datePicker setDatePickerMode:UIDatePickerModeDateAndTime]; } else { alertTitleString=@"Select Time"; [datePicker setDatePickerMode:UIDatePickerModeTime]; } [datePicker setDate:[NSDate date]]; UIView *view = [[datePicker subviews] objectAtIndex:0]; [view setBackgroundColor:[UIColor clearColor]]; // hide the first […]

从viewDidLoad显示警报消息

我想显示从ViewController.m viewDidLoad()方法,而不是从viewDidAppear()方法的警报消息。 这是我的代码: – (void)viewDidLoad { [super viewDidLoad]; //A SIMPLE ALERT DIALOG UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"My Title" message:@"Enter User Credentials" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { NSLog(@"Cancel action"); }]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { NSLog(@"OK action"); }]; [alert addAction:cancelAction]; [alert addAction:okAction]; [self […]