Tag: uialertview

在iOS中离开视图之前要求用户确认

我需要在用户离开某个视图之前显示一个UIAlertView ,或者点击一个“后退”导航栏button,或者点击我拥有的标签栏中的一个标签项,以便要求他确认。 这将是一个双button提醒,一个“取消”一个留在视图中,一个“接受”一个离开。 我需要这样做,因为我必须让用户意识到如果离开,未保存的更改将会丢失。 我试图通过在viewWillDisappear:方法中创build并显示警报视图来执行此操作: – (void)viewWillDisappear:(BOOL)animated { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Exit", @"") message:NSLocalizedString(@"Are you sure you want to leave? Changes will be discarded", @"") delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", @"") otherButtonTitles:NSLocalizedString(@"Accept", @""), nil]; [alertView show]; [super viewWillDisappear:animated]; } 但是,无论如何,视图是popup窗口,警告视图显示之后,应用程序崩溃,因为它的委托是已经从导航堆栈已经popup的视图控制器…我没有find解决这个情况的方法,可以有人帮我吗? 谢谢!

用UIAlertViewStylePlainTextInput编辑注释文本

我可以将引脚标注放到具有泄露button的地图上。 当单击该button时,会popup一个alertView,在其中可以删除选定的注释。 我现在正在尝试使用UIAlertViewStylePlainTextInput编辑选定的注释字幕。 任何想法如何我可以做到这一点? – (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { NSLog(@"Annotation button clicked"); UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Annotation" message:@"Edit Subtitle" delegate:self cancelButtonTitle:@"Hide" otherButtonTitles:@"Update Subtitle", @"Remove Pin",nil]; alert.alertViewStyle = UIAlertViewStylePlainTextInput; [alert show]; } – (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 0) { NSLog(@"Hide button clicked"); } if (buttonIndex == 1) { NSLog(@"Update […]

UIAlertViews在IOS7string长度限制?

我在一个新的iOS应用程序工作,我注意到以下问题在iOS7环境中安装应用程序。 第一次打开应用程序后,我们的应用程序显示一个popup式窗口,需要接受的AGB才能开始使用。 我们使用了一个UIAlertView ,它工作正常,直到我们用iOS7进行testing。 其实这个警报popup,似乎有内容,因为我可以看到一个巨大的滚动条! 但奇怪的是,文本是根本没有显示….玩了一下文本后,我注意到,iOS7的新UIAlertView有一些types的string长度限制… 有其他人注意到了吗? 这是正常的,还是iOS 7的错误? 我发现自定义 UIAlertView作品,但我宁愿使用本地API,如果可能的话。

通过layoutSubviews => UIAlertButton类未find自定义UIAlertButton

我试图使用本教程实现自定义警报视图。 所有在这个啧啧啧啧啧啧啧啧啧啧啧but but的,但它并没有谈到定制UIAlertButton 然后,我试图通过layoutSubviews方法来定制它: – (void)layoutSubviews { for (UIView *subview in self.subviews){ //Fast Enumeration if ([subview isMemberOfClass:[UIImageView class]]) { subview.hidden = YES; //Hide UIImageView Containing Blue Background } if ([subview isMemberOfClass:[UILabel class]]) { //Point to UILabels To Change Text UILabel *label = (UILabel*)subview; //Cast From UIView to UILabel label.textColor = [UIColor colorWithRed:210.0f/255.0f green:210.0f/255.0f blue:210.0f/255.0f alpha:1.0f]; […]

调用iOS Alert时出现UI一致性错误

我有一个iOS Xamarin项目,我收到以下错误: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread. 以下代码会发生此错误: 在我的欢迎视图页面中,我有一个名为SyncButton的button被点击。 该button的点击应该使用REST将数据与服务器进行同步。 在我的WelcomeController中我有: …. SyncButton.TouchUpInside += async (object sender, EventArgs e) => { SyncButton.Enabled = false; await welcomeDelegate.syncButtonCore (cred, iOSErrorAlert); SyncButton.Enabled = true; }; …. public void iOSErrorAlert(string LoginErrorTitle, string LoginErrorMessage){ var Alert = […]

访问alertView的调用视图

我有一个UIAlertView,当用户想要删除一个RegionAnnotation时,它显示为一个确认。 我很难找出如何访问RegionAnnotationView调用我需要为了删除RegionAnnotation的UIAlertView。 这里是我破碎的代码 – 你可以看到我试图将AlertView的超级视图投射到RegionAnnotationView的位置(一个公认的坏主意)。 – (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(buttonIndex==0) { NSLog(@"alertView.superview is a %@",alertView.superview); RegionAnnotationView *regionView = (RegionAnnotationView *)alertView.superview; RegionAnnotation *regionAnnotation = (RegionAnnotation *)regionView.annotation; [self.locationManager stopMonitoringForRegion:regionAnnotation.region]; [regionView removeRadiusOverlay]; [self.mapView removeAnnotation:regionAnnotation]; } }

iOS:有没有办法使一个viewcontroller看起来不活动一切变灰?

我希望我的ViewController和每个对象都显示为非活动状态(类似于UIAlertViewpopup窗口如何灰色背景中的所有内容)。 我不想手动灰化每个对象。是否有一个简单的方法来做到这一点?

我怎样才能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];

检测Internet连接并显示UIAlertview Swift 3

我正在做一个应用程序,检测是否有连接到互联网通过使用if语句,当有互联网,什么也不做,但如果没有互联网连接,然后警报视图说应用程序需要互联网我pipe理发现可达性但在我的viewDidLoad()上实现uialertview似乎不工作。 我正在使用这个: public class Reachability { class func isConnectedToNetwork() -> Bool { var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) zeroAddress.sin_len = UInt8(MemoryLayout.size(ofValue: zeroAddress)) zeroAddress.sin_family = sa_family_t(AF_INET) let defaultRouteReachability = withUnsafePointer(to: &zeroAddress) { $0.withMemoryRebound(to: sockaddr.self, capacity: 1) {zeroSockAddress in SCNetworkReachabilityCreateWithAddress(nil, zeroSockAddress) } […]

如何在UIAlertView(iOS)中的其他两个button(堆叠)之间添加Cancelbutton

我想创build一个UIAlertView与三个button(将被堆叠)。 我想要取消button在两个其他button之间的中间。 我已经尝试将cancelButtonIndex设置为1,但是如果有两个其他button,它只是将它们放置在索引0和1.我知道我可以只更改button的名称,但我想要取消button的深蓝色格式。 编辑:**请注意 – 我知道如何得到正确的顺序标题的三个button,但只有当所有三个button本质上看起来像“其他”button; 我想取消button有取消button深蓝色背景 ,使它看起来像一个常规的取消button。 ** 我试过了 UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:button1Title,button2Title,nil] autorelease]; alert.cancelButtonIndex = 1; [alert show]; 和 UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] autorelease]; alert.cancelButtonIndex = 1; [alert addButtonWithTitle:button1Title]; [alert addButtonWithTitle:button2Title]; [alert show]; 和 UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:title message:msg […]