ios - 提示用户输入并存储数据

标签 ios objective-c uialertview

我刚开始 iOS 开发,现在卡住了。我有一个表格单元格,用户可以在其中查看数据。在它旁边,有两个按钮。一个要删除,一个要编辑。编辑部分是我卡住的地方。我有一个标签字段。当用户点击编辑按钮时,应该出现一个提示,用户可以在其中输入数据。我已经找到了可以做的事情。但是没有保存按钮,我不知道如何将变量保存到 NSString

UIAlertView * alert     = [[UIAlertView alloc] initWithTitle:@"Name der neuen Liste" message:@"" delegate:self cancelButtonTitle:@"Abbrechen" otherButtonTitles:nil];
alert.alertViewStyle    = UIAlertViewStylePlainTextInput;
[alert show];

我现在有这个。 l现在弹出提示,可以写东西,但不能保存。之后我可以按取消。如何在 iOS 中处理用户输入?我不想将标签用作 UITextField,因为它必须可点击才能执行其他操作。

最佳答案

试试这个:

- (void)noteInput
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"input"
                                                    message:@"input"
                                                   delegate:self
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"Save", nil];

    [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
    [alertView show];

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{
    if(buttonIndex == 1)
    {
        UITextField *noteText = [alertView textFieldAtIndex:0];
        NSString *note = noteText.text;
    }
}

关于ios - 提示用户输入并存储数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20546156/

相关文章:

iphone - 在 iTunes 中向我的应用添加评论或星标

iOS如何在UITableView中显示数组字典

ios - Swift - 创建自定义 View 的不同实例

ios - Objective-C ARC block __strong __weak

ios - map 上的自定义图钉(注释)动画

ios - 更改 UIAlertViewController 色调颜色

ios - 即使应用程序未运行,网络扩展也可监控 WiFi 网络变化

objective-c - 如何在 iOS 中使用 AssistiveTouch UI

ios - ZLib压缩方法中的隐式转换会失去整数精度

iphone - UIAlertView 的私有(private)方法崩溃