相关疑难解决方法(0)

通过触摸UITableView的背景来关闭键盘

我有一个UITableViewUITextFieldS作为细胞.当UITableView触摸背景时,我想解除键盘.我试图通过创建一个UIButton大小UITableView并将其放在后面来做到这一点UITableView.唯一的问题是,UIButton即使触摸在UITableView上,也能捕获所有触摸.我究竟做错了什么?

谢谢!

uitableview uikeyboard ios

102
推荐指数
11
解决办法
8万
查看次数

当键盘出现在iOS中时,向上移动UIView

我有一个UIView,它不在UIScrollView中.我想在键盘出现时向上移动我的视图.在我尝试使用此解决方案之前:如何在键盘存在时使UITextField向上移动?.

它工作正常.但是在文本字段中插入数据后,它会转到另一个视图,当我回到这个页面时,它只是跳跃,我看不到我的文本字段.有没有更好的解决方案来解决这个问题?

xcode objective-c uiviewcontroller uiview ios

71
推荐指数
9
解决办法
11万
查看次数

用户点击文本域外的其他区域时如何关闭键盘?

今天我试着在我的iPod(iOS 6.1.3)上运行我的代码,我在这里发现了一些有趣的东西......

首先,当我点击文本字段时,键盘会显示,但当我点击文本字段外的其他位置时,它不会隐藏.

所以我决定使用Google搜索并找到了这个解决方案:

_fieldEmail.delegate = self;
_fieldEmail.returnKeyType = UIReturnKeyDone;

_fieldPassword.delegate = self;
_fieldPassword.returnKeyType = UIReturnKeyDone;

_fieldRegisterName.delegate = self;
_fieldRegisterName.returnKeyType = UIReturnKeyDone;

_fieldRegisterEmail.delegate = self;
_fieldRegisterEmail.returnKeyType = UIReturnKeyDone;

_fieldRegisterPassword.delegate = self;
_fieldRegisterPassword.returnKeyType = UIReturnKeyDone;
Run Code Online (Sandbox Code Playgroud)

它有效...它在键盘底部给出一个"完成"按钮,现在可以通过按下它来隐藏键盘.

但我这里有两个问题:

  1. 键盘只有在点击"完成"按钮时才会隐藏.不要通过点击文本字段外的其他区域.我不知道iOS世界是否正常,但通常我看到很多应用程序都不像这样.
  2. 有没有办法循环这个过程所以我没有手动添加该委托我所拥有的所有文本域?怎么做?

这就是我需要知道的

objective-c ios

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

在UITextView上失去焦点时隐藏键盘

所以我有一个UITextView,我用它来允许用户提交一些文本.

我的问题是,我似乎无法弄清楚如何通过点击UITextView来允许用户"取消".

iphone cocoa-touch objective-c uitextview uikit

45
推荐指数
3
解决办法
4万
查看次数

用户在文本框外单击时隐藏在iOS键盘中

当用户在文本字段外单击时,我试图隐藏iPad软键盘.

特别是在形式或主体上不包含其他元素的某处.

使用jquery,jquery mobile和html5.

javascript jquery html5 ipad ios

9
推荐指数
2
解决办法
7690
查看次数

触摸屏幕时如何隐藏键盘(搜索栏)

单击搜索或单击取消时键盘隐藏.但是我也希望当我点击屏幕上的某个地方时键盘会隐藏.我找到了几个文本教程,但我们正在使用搜索栏.

谁能告诉我怎么做?

谢谢.

keyboard hide ios searchbar

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

UiTextField和resignFirstResponder

我有一个奇怪的设置.

我有一个View名为View1和一个ViewController调用viewController1

IB,View1ViewController1的子代.

View1中,我使用代码a创建UITextField并添加为子视图.

在我Viewcontroller,我有viewController1 : UIViewController <UITextFieldDelegate>

现在..我想在View1中的文本字段获得键盘中的"完成"按钮时重新签名键盘,所以我有

- (BOOL)textFieldShouldReturn:(UITextField *)TEXTFIELD {
    [TEXTFIELD resignFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)

现在的问题是,如何在TEXTFIELD(在我的viewcontroller中定义)和我的View中定义的文本字段之间建立连接?

我是否必须在interfaceBuilder中执行某些操作?

也许我完全不在这里......

一些提示非常感谢

iphone uiviewcontroller first-responder

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

将光标隐藏在UITextView - Swift上

我有一个具有用户反馈功能的应用.我已经完成了图像中所示的视图. 我做的反馈意见

  • 消息区域正在使用UITextView.

我现在要做的是当用户完成编辑textView,然后点击其他地方,如星级或文本视图以外的任何区域,它会将光标隐藏在textview上,但它会同时保留书面文字.

谁能帮我这个?谢谢.

uitextview ios swift

4
推荐指数
2
解决办法
4915
查看次数

在文本字段外面隐藏键盘

我试图在屏幕上的任何其他地方触摸后隐藏键盘.我正在使用的代码基于这里的答案.

IBOutlet UITextView *myTextView;
Run Code Online (Sandbox Code Playgroud)

方法:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject];
    if ([myTextView isFirstResponder] && [touch view] != myTextView) {
        [myTextView resignFirstResponder];
    }
    [super touchesBegan:touches withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)

我不明白的是我应该如何将我的UITextField链接到该touchesBegan方法.我需要使用哪个发送的事件?此外,该方法不应该是IBAction,因为现在我无法将我的UITextField连接到它.

我也尝试了这个代码,但那个代码打破了我的导航按钮(即使是评论中提到的解决方案)

uitextfield uikeyboard ios

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

下一个按钮将焦点带到下一个UITextField?

我有三个UITextFields,我需要第一个选项卡到第二个时候点击下一个,第二个选项卡到第三个时候点击下一个.最后是第三个隐藏键盘.作为一个侧面问题,用户可以通过点击所有文本字段上屏幕上的任何其他位置来隐藏键盘吗?

这是我的代码:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


-(void) procrastinationNotificationSwitchOnOrOff {

    if (_procrastinationNotificationSwitch.on) {
        _notificationOnOffLabel.text = @"Procrastination Notification On";
        self.notificationStatus = @"NOTIFICATION ON";
        NSLog(self.notificationStatus);
    }
    else {
        _notificationOnOffLabel.text = @"Procrastination Notification Off";
        self.notificationStatus = @"NOTIFICATION OFF";
        NSLog(self.notificationStatus);
    }
}


-(void) presentMessage:(NSString *)message {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Class Stuff" message:message delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
    [alert show];

}

-(void) notificationStatus:(NSString *)stat {
   NSString *status = [NSString stringWithFormat:@"%@", stat];

}

-(IBAction)addButton:(id)sender {


    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    dateFormatter.timeZone = …
Run Code Online (Sandbox Code Playgroud)

objective-c uitextfield ios

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

UITextfield在UITableViewCells中 - 关闭键盘

UITextfields在每个表格单元格中都有几个.通过点击"完成"按钮或触摸键盘外部,键盘应该被解除.

我的问题:textFieldShouldEndEditing只有当我点击另一个文本字段并且键盘不会被解除时才调用该方法.我想我已经实现了必要的部分(委托和协议方法).

有谁知道我在这里失踪了....?

这是代码(相关部分):

class myVC: UIViewController, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate  {...
Run Code Online (Sandbox Code Playgroud)

这是细胞设置......

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
    let tcell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "tbCell")

    let textfield: UITextField = UITextField(frame:...

    switch (indexPath.section) {
    case 0: ...
    case 1: 
            textfield.text = section2[indexPath.row]
            tcell.addSubview(textfield)
            textfield.delegate = self
            return tcell
Run Code Online (Sandbox Code Playgroud)

这个协议方法:

func textFieldShouldEndEditing(textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        print("method is called")
        return true
    }
Run Code Online (Sandbox Code Playgroud)

谢谢!

uitextfield ios uitextfielddelegate swift

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