Tag: uialertcontroller

我怎样才能closuresUIAlertController没有button

我使用UIAlertController和UIActivityIndi​​catorView作为我的加载指示器,它将closures直到我的应用程序获得服务器响应。 但是当我的服务器或networking出现问题时,我的应用程序永远不会得到响应,我无法从AlertView取回我的控制权,我想知道是否有一些方法可以通过触摸屏幕closures此AlertView。 而我的UIAlertView是没有标题和任何button。 任何提示将是感恩。 当我触摸屏幕时它崩溃了,下面是我的代码: UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"正在装载页面…\n\n" preferredStyle:UIAlertControllerStyleAlert]; UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; spinner.center = CGPointMake(130.5, 65.6); spinner.color = [UIColor darkGrayColor]; [spinner startAnimating]; [alert.view addSubview:spinner]; UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc]initWithTarget:alert action:@selector(stopWaiting)]; [alert.view addGestureRecognizer:recognizer];

CLLocation提示显示并在一瞬间消失

在我的应用程序,我尝试从GPS获取经度和纬度。 要做到这一点,我必须要求用户有权访问他的位置。 在我这样做之前,我添加到Info.plist这两个规则: Privacy – Location When In Use Usage Description和Privacy – Location Always Usage Description ,然后在AppDelegate询问有关执行此操作的权限(SWIFT 3.0): if CLLocationManager.locationServicesEnabled() == true { let localisationManager = CLLocationManager() localisationManager.requestWhenInUseAuthorization() localisationManager.startUpdatingLocation() } 在运行应用程序的同时,我可以看到UIAlertController ,但几乎在同一时间它消失,我没有时间点击Allow ,我不能使用GPS。 如何解决它? 我的问题的工作解决scheme: 我在class LocationManager and then I used it in function.创build了单独的variablesvar locationManager = CLLocationManager() class LocationManager and then I used it in […]

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

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

内存泄漏在Swift中使用UIAlertController

我提出了一个简单的UIViewController使用这个简单的代码 @IBAction func addNewFeed(sender: UIBarButtonItem) { var alertView: UIAlertController? = UIAlertController(title: NSLocalizedString("New Feed", comment: "Titolo popup creazione feed"), message: NSLocalizedString("Insert the Title and the Link for the new Feed.", comment: "Messaggio creazione nuovo feed"), preferredStyle: UIAlertControllerStyle.Alert) alertView!.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: "Annulla popup creazione nuovo feed"), style: UIAlertActionStyle.Cancel, handler: nil)) presentViewController(alertView!, animated: true, completion: nil) } 当我按下我的界面上的button,我把这个IBAction和UIAlertController出现。 […]

如何在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消失?

UIAlertController自定义字体不适用于iOS

UIAlertController自定义字体不起作用。 下面的代码是一个函数ShowActionSheetAsync ,显示ActionSheet 。 在这一点上,我想改变ActionSheet的字体。 我尝试了几种方法,但效果不佳。 有没有好的解决scheme? public Task<bool> ShowActionSheetAsync() { var source = new TaskCompletionSource<bool>(); var alert = new UIAlertController { Title = "title" }; alert.AddAction(UIAlertAction.Create( "button1", UIAlertActionStyle.Default, _ => source.SetResult(true))); alert.AddAction(UIAlertAction.Create( "cancel", UIAlertActionStyle.Cancel, _ => source.SetResult(false))); // [Block 1] var viewController = UIApplication.SharedApplication.KeyWindow.RootViewController; ViewController.PresentViewController(alert, true, delegate { // [Block 2] }); // [Block […]

Swift尝试呈现其视图不在窗口层次结构中的UIAlertController(在TWTRShareEmailViewController之后呈现)

我在我的应用程序的注册过程中使用Twitterlogin。 我要求用户的电子邮件。 一旦我得到它,我想提出一个UIAlertController。 这是我的代码: func askForTWMail(){ if (Twitter.sharedInstance().session() != nil) { let shareMailVC=TWTRShareEmailViewController(completion: {(mail:String!, error:NSError!) in if (mail != nil) { print("GOT MAIL: \(mail)") self.gotMail() }else{ print("MAIL VC ERROR: \(error)") } }) println("PRESENT MAIL VC") self.presentViewController(shareMailVC, animated: true, completion: nil) }else{ println("User not logged in") } } func gotMail(){ var alertController=UIAlertController(title: "Some title", message: "Some […]

iOS AlertView应用程序扩展

我正在使用自定义keyboard (iOS App Extension) 。 我有一个UICollectionView在我的Keyboard Layout ,所以当一个item被选中,我想显示一个message (例如UIAlerView )。 这是我的代码: – (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ … UIAlertController * alert= [UIAlertController alertControllerWithTitle:@"My Title" message:@"Enter User Credentials" preferredStyle:UIAlertControllerStyleAlert]; [self presentViewController:alert animated:YES completion:nil]; } 我得到这个错误: 'Feature not available in extensions of type com.apple.keyboard-service' 所以…有什么办法显示来自App Extension的message ? 编辑: 这是一个例子。 IKEA Emoticons Keyboard显示一条消息(如select一个项目后的Android Toast )。 我也试过这个库: iOS Toast图书馆

从自定义类中显示alertController

我试图从我所做的类中显示一个AlertController。 由于AlertController是UIResponder的一个子类,我正在使用Xcode提示我的以下代码行 superclass?.presentViewController(alertController, animated: true, completion: nil) 但是我不能编译,因为AnyClass? 没有任何成员presentViewController。 我的类是NSObject的一个子类。 任何其他解决scheme 谢谢

警告:不鼓励在分离的视图控制器上呈现视图控制器

我的情况与我在这里find的其他所有例子都不一样。 我有一个基于标签的应用程序。 在其中一个选项卡上,用户可以按下一个button,一次从Web服务器下载多个文件。 我使用NSOperation来执行这些下载,以便我可以利用内置的依赖关系。 下载全部发生在后台线程上,所以应用程序保持响应。 当最后的下载完成后,我在屏幕上放置一个alertController让用户知道它们是完整的。 如果用户在呈现警报控制器时select了不同的选项卡,则会显示警告:“不鼓励在分离的视图控制器上呈现视图控制器” 如果他们仍然在开始下载的标签,那么我不会收到警告。 我试过replace: [self presentViewController:alertController animated:YES completion:nil]; 同 [self.view.window.rootViewController presentViewController:alertController animated:YES completion:nil]; 但结果是alertController从不呈现。 我正在主线程上呈现alertController。 我无法预测下载完成时用户将使用的选项卡视图控制器,并且真的想要摆脱此警告。 我正在使用Obj-C在macOS和Xcode 8上开发。