标签: alertview

如何在iPhone中的UIAlertView中添加UITableView?

我想在警报视图中添加UItableview.

我试图添加一个表视图作为警报视图的子视图,它不起作用.你能给我一些代码或示例链接吗?

我怎样才能做到这一点?

谢谢

iphone uitableview alertview

6
推荐指数
2
解决办法
2万
查看次数

UIALertView带有文本的多个按钮

我有一个带有3个按钮和文本的警报视图(标签而不是textView)如果我将它们全部卡在一起,这个微小的滚动文本和占据大部分空间的所有按钮都会变得难看.有谁知道如何解决这一问题?

iphone xcode button alertview

5
推荐指数
2
解决办法
1万
查看次数

键盘打开后视图更改后出现带有白色文本的ios黑色键盘

我正在为我的标准TextField使用"黑暗"式键盘.这是用于登录文本字段,或"忘记我的密码"文本字段,用户在其中输入一些信息,提交它,如果成功,则将它们发送到另一个视图,通常由标准导航控制器popViewControllerAanimated:.AlertView可能出现在两者之间.

我看到很多问题是键盘是打开的,正常的"深色"灰色,然后用户点击提交,可能会出现一个警报视图,当解雇时,视图转移到下一个屏幕以前的键盘关闭屏幕.在新屏幕上,另一个默认样式键盘可能会或可能不会向上滑动然后消失(甚至没有文本域聚焦!).然后,当点击另一个文本字段,或返回上一个视图并单击文本字段时,这个带有白键的黑色键盘会出现错误.它会继续出现在文本字段中,直到某些内容能够在几次单击后将其恢复为正常的深灰色.

我试图在popViewController发生之前以各种方式解除原始键盘,但它似乎没有帮助.如果AlertView出现在中间,我在单击AlertView按钮时将popViewController绑定到委托操作.键盘通常不会快速消失,在推动前离开.延迟对它没有帮助.

编辑:警报视图似乎是一个明确的罪魁祸首,以某种方式干扰弹出和键盘.

-(BOOL) textFieldShouldReturn:(UITextField *)textField{
    [textfield resignFirstResponder];
    [self.view endEditing:YES];
    return YES;
}

-(IBAction)submitRequest {
    [textfield resignFirstResponder];
    [self.view endEditing:YES];

    // make API call, if call succeeds run this block {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"..."
                                                message:@"..."
                                               delegate:delegate
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles:nil, nil];
          dispatch_async(dispatch_get_main_queue(), ^{
            [alert show];
          });         
    // }
}

// delegate after alert OK is pressed
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  [self.navigationController popViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

如何避免使用黑/白键盘?

在此输入图像描述

keyboard ios alertview

5
推荐指数
1
解决办法
629
查看次数

iOS-如何在代码启动之前显示alertView

我有以下代码:

-(IBAction)showAlertView:(id)sender{

alertView = [[UIAlertView alloc] initWithTitle:@"Atualizando" message:@"\n"delegate:self cancelButtonTitle:nil otherButtonTitles:nil];

spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];   
spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
[alertView addSubview:spinner];
[spinner startAnimating];
[alertView show]; 
}


-(IBAction)getContacts:(id)sender {

[self showAlertView:(id)self];

ABAddressBookRef addressBook = ABAddressBookCreate( );
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );
Run Code Online (Sandbox Code Playgroud)

我希望在IBAction的其余部分开始之前显示警报,但我只在IBAction结束时看到alertView.我究竟做错了什么?

编辑:我有:

-(IBAction)getContacts:(id)sender {

// display the alert view
[self showAlertView:self];

// do the synchronous operation on a different queue
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

ABAddressBookRef addressBook = …
Run Code Online (Sandbox Code Playgroud)

iphone ibaction ios alertview

2
推荐指数
1
解决办法
1436
查看次数

按钮上的iOS alertview操作

我在菜单中有一个按钮,当触摸时,会弹出一个警告消息,其中包含两个按钮:" Cancel"和" Yes".这是我对警报的代码:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Exit game"
                                                message:@"Are you sure?"
                                               delegate:nil
                                      cancelButtonTitle:@"Cancel"
                                      otherButtonTitles:@"Yes", nil];
[alert show];
Run Code Online (Sandbox Code Playgroud)

是否可以在按钮" Yes"中添加动作?

xcode ios alertview

2
推荐指数
1
解决办法
1万
查看次数

使用shouldPerformSegueWithIdentifier在swift中取消segue

我有一个功能,检查登录是否正确.如果没问题,我会显示下一个屏幕.如果用户不正确,我取消segue并显示警告.

问题出现的原因是当我在shouldPerformSegueWithIdentifier函数中调用此函数时,我给布尔变量赋值(如果用户是否正确),那么shouldPerformSegueWithIdentifier的返回值就是这个布尔值.问题是它没有采用该值并保持默认值.这是我的代码:

override func shouldPerformSegueWithIdentifier(identifier: String!, sender: AnyObject!) -> Bool {

    var userIsCorrect = false //THIS IS THE BOOLEAN

    if identifier == "fromLogInToGetIn" {

        self.loginRequest("http://myurl.com",

            withParams: ["email":"email@email.com","password":"password"])

        {

            (succeeded: Bool, msg: String) -> () in

            var alert = UIAlertView(title: "Success!", message: msg, delegate: nil, cancelButtonTitle: "Okay.")

            if(succeeded) {

                if msg == "0"

                {

                    userIsCorrect = false // BOOLEAN DOES NOT TAKE THE VALUE

                    alert.title = "Error"

                    alert.message = "Incorrect user"

                }

                else

                {

                    userIsCorrect = true // BOOLEAN DOES NOT …
Run Code Online (Sandbox Code Playgroud)

ios alertview segue uistoryboardsegue swift

2
推荐指数
1
解决办法
3661
查看次数

带视图控制器的Xcode和alertview

我想要实现的是在单击我的警报视图按钮时转到另一个视图.我的警报视图在我的loadingView中,这个警报视图是从另一个名为classA的类中调用的.

这就是它在classA中的调用方式.

[LoadingViewController showError];
Run Code Online (Sandbox Code Playgroud)

这是在loadingView类中加载View的方法.

+ (void)showDestinationError{
UIAlertView *alert = [[UIAlertView alloc] 
                      initWithTitle:@"Error" 
                      message:@"Error"
                      delegate:self 
                      cancelButtonTitle:@"OK" 
                      otherButtonTitles: nil];
alert.tag = DEST_ERR;
[alert show];
}
Run Code Online (Sandbox Code Playgroud)

按钮动作

+ (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag = DEST_ERR){

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
    UINavigationController *secondView = [storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];
    secondView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;    
    [secondView presentModalViewController:secondView animated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误.'应用程序试图在其自身上呈现模态视图控制器.呈现控制器是UINavigationController:..

注意:我的方法是'+'

xcode viewcontroller alertview

1
推荐指数
1
解决办法
3996
查看次数

如何将文本字段添加到警报视图?Xcode 4.5 iOS6

如何在alertview中添加文本字段?我正在尝试做一个应用程序,在应用程序提交编辑之前,用户必须通过在所述alertview上键入他/她的密码来验证第一,但我该怎么做?似乎我搜索的代码不再起作用了.这里是:

  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Log In" message:@"Please enter your Password" delegate:self cancelButtonTitle:@"Log In" otherButtonTitles:@"Cancel", nil];
    [alert addTextFieldWithValue:@"" label:@"Password"];
    UITextField *tf = [alert textFieldAtIndex:0];
    tf.clearButtonMode = UITextFieldViewModeWhileEditing;
    tf.keyboardType = UIKeyboardTypeAlphabet;
    tf.keyboardAppearance = UIKeyboardAppearanceAlert;
    tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
    tf.autocapitalizationType = UITextAutocorrectionTypeNo;
Run Code Online (Sandbox Code Playgroud)

错误说

 "No visible @interface for 'UIAlertView' 
 declares the selector 'addTextFieldWithValue:label:'" 
 on the [alert addTextFieldWithValue:@"" label:@"Password"];
Run Code Online (Sandbox Code Playgroud)

我还想问一下如何将代码放在alertview上的Confirm按钮上.

xcode ios alertview

1
推荐指数
1
解决办法
2154
查看次数

如何在UIAlertView的中心添加UIActivityIndi​​catorView?

作为标题,我想在UIAlertView实例的中心添加一个UIActivityIndi​​catorView实例.这是我的代码:

    alertView  = [[UIAlertView alloc]initWithTitle:@"Processing" message:@"" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];

    CGRect screenRect = [[UIScreen mainScreen] bounds];
indicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(screenRect.size.width/2, screenRect.size.height/2,50,50)];
[alertView addSubview: indicator];
[indicator startAnimating];
[alertView show];
Run Code Online (Sandbox Code Playgroud)

我看到的只是alertView.我犯了什么错吗?

uiactivityindicatorview ios alertview

1
推荐指数
1
解决办法
1万
查看次数