uialertview

Using OCUnit to test if an UIAlertView is presented

╄→尐↘猪︶ㄣ 提交于 2019-12-03 16:01:36
I'm working on an app that will display a UIAlertView upon hitting it's exit button, only if progress in the game has been made. I was wondering how you would use OCUnit to intercept the UIAlertView and interact with it, or even detect if it has been presented. The only thing I can think of is to monkeypatch [UIAlertViewDelegate willPresentAlertView] , but that makes me want to cry. Does anyone know of a better method of doing this? Update : See my blog post How to Unit Test Your Alerts and Action Sheets The problem with my other answer is that the -showAlertWithMessage: method itself is never

UIAlertAction handler running after delay

爱⌒轻易说出口 提交于 2019-12-03 15:37:31
问题 I'm trying to change my UIAlertViews to UIAlertControllers. I set up this action for it: UIAlertAction *undoStopAction = [UIAlertAction actionWithTitle:@"Undo Stop" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self undoStop]; }]; But, the handler doesn't run until about a second after the action is tapped. Is there any way to speed this up? 回答1: The short delay is normal for Alert View (less than a second though). If this is not convenient for you, you can

Adding Activity Indicator to UIAlertView

霸气de小男生 提交于 2019-12-03 12:37:02
问题 I'm trying to add UIActivityIndicatorView to UIAlertView but couldn't get it done. I have seen posts on this implementation and found out that it works only for versions below iOS7. Below is the code I've tried... var alert: UIAlertView = UIAlertView(title: "Title", message: "Please wait...", delegate: nil, cancelButtonTitle: "Cancel"); var loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(0.0, 0.0, 10.0, 10.0)) as UIActivityIndicatorView loadingIndicator

Keyboard will appeared automatically in ios 8.3 while displaying alertview or alertcontroller

妖精的绣舞 提交于 2019-12-03 12:27:13
I have updated Xcode 6.3 and ios8.3 check my code. then it gives me weird result. here is first screen of my demo app. here is one textfield. when I type somethin in textfield keyboard open. after typing completed. I have clicked on show alert button. I have displayed alert and output will be following. After click on cancel. I have displayed another alert then weird result keyboard should not open but when click on cancel button. display another alert and keyboard will appear automatically. here is next screen output following is the code - (IBAction)MethodShowAlert:(id)sender { [tmptxtField

Check if Google Maps App is installed in iOS 6

家住魔仙堡 提交于 2019-12-03 12:07:34
I am trying to figure out how to handle the result of this code to see if Google Maps is installed in the app. [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://"]]; I am creating a UIAlertView with the option in there and if it is or isn't I wish to give the user different options. How do I take the result of the code above and turn it into a BOOLEAN? Thanks in advance. The result is already of canOpenURL: a boolean: BOOL canHandle = [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps:"]]; if (canHandle) { // Google maps

UI issue with nil title in UIAlertView iOS 8 beta 5

人盡茶涼 提交于 2019-12-03 11:49:00
I have an issue related to UIAlertView while running our app on iOS 8. I am showing an alert with title as nil. It was working fine in iOS 7 but now UI looks odd. I have attached screenshot here. One solution I found is that when I provide empty string @“” it looks okay. See below screenshot. But I am not sure if the issue I mentioned is bug in beta iOS 8 version or if there is any other better solution. Even with the solution it's not exact as it was in iOS 7. iOS 7 - showing alert view with title as nil. Screenshot here. It has been the best practice for me to use initWithTitle:@"" for

dismissing a UIAlertView programmatically

假如想象 提交于 2019-12-03 10:54:10
I need help on dismissing a UIAlertView programmatically. Currently I have this UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; then later on I call this [alert1 dismissWithClickedButtonIndex:0 animated:NO]; but nothing happens. Arun You need to set two things. 1. include your .h file : <UIAlertViewDelegate> 2. please follow below implementation... UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; [alert1

Swift: Insert Alert Box with Text Input (and Store Text Input )

对着背影说爱祢 提交于 2019-12-03 10:11:54
In one of my viewController , I want to make an alert box appear that prompts the user to type this information.Then, I want the user to store this input using NSUserDefaults . How can I achieve this? Thank you in advance! Andrei Papancea Check this out: let alertController = UIAlertController(title: "Email?", message: "Please input your email:", preferredStyle: .alert) let confirmAction = UIAlertAction(title: "Confirm", style: .default) { (_) in guard let textFields = alertController.textFields, textFields.count > 0 else { // Could not find textfield return } let field = textFields[0] //

IOS基础UI之(五)UIAlertView、UIActionSheet和UIAlertContro

删除回忆录丶 提交于 2019-12-03 09:56:00
IOS基础UI之(五)UIAlertView、UIActionSheet和UIAlertController详解 标签: ios UIAlertView UIActionSheet UIAlertController 2015-09-20 11:58 340人阅读 评论 (3) 收藏 举报 分类: IOS(UI基础)(10) 版权声明:本文为博主原创文章,未经博主允许不得转载。 iOS 8的新特性之一就是让接口更有适应性、更灵活,因此许多视图控制器的实现方式发生了巨大的变化。 比如说Alert Views、Action Sheets。 下面就大致介绍它们的使用方式。 UIAlertView: 1.创建 UIAlertView。 UIAlertView的按钮是水平排列的,当按钮多的时候由于考虑的位置不够,因此会垂直排列。 参数:delegate: 代理 otherButtonTitles: 其它按钮,可以添加多个。多个用逗号隔开 [objc] view plain copy UIAlertView *alert = [[UIAlertView alloc ]initWithTitle: @"标题" message : @"这个是UIAlertViewStyleDefault的默认样式" delegate : self cancelButtonTitle : @"取消"

Add image to alert view

笑着哭i 提交于 2019-12-03 09:08:30
问题 I have an alert view that pops up when the user press the add button. How do i add an image to the alert view? I added some code that i took reference from stack overflow. My save button is replaced with the image and the image appear to be in blue colour... Code for Alert View var alert = UIAlertController(title: "Spring Element \(springNumber)", message: "Add spring properties", preferredStyle: .Alert) let saveAction = UIAlertAction(title: "Save", style: .Default) { (action: UIAlertAction!)