我有一个UITableView
与UITextField
S作为细胞.当UITableView
触摸背景时,我想解除键盘.我试图通过创建一个UIButton
大小UITableView
并将其放在后面来做到这一点UITableView
.唯一的问题是,UIButton
即使触摸在UITableView上,也能捕获所有触摸.我究竟做错了什么?
谢谢!
我有一个UIView,它不在UIScrollView中.我想在键盘出现时向上移动我的视图.在我尝试使用此解决方案之前:如何在键盘存在时使UITextField向上移动?.
它工作正常.但是在文本字段中插入数据后,它会转到另一个视图,当我回到这个页面时,它只是跳跃,我看不到我的文本字段.有没有更好的解决方案来解决这个问题?
今天我试着在我的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)
它有效...它在键盘底部给出一个"完成"按钮,现在可以通过按下它来隐藏键盘.
但我这里有两个问题:
这就是我需要知道的
所以我有一个UITextView,我用它来允许用户提交一些文本.
我的问题是,我似乎无法弄清楚如何通过点击UITextView来允许用户"取消".
当用户在文本字段外单击时,我试图隐藏iPad软键盘.
特别是在形式或主体上不包含其他元素的某处.
使用jquery,jquery mobile和html5.
单击搜索或单击取消时键盘隐藏.但是我也希望当我点击屏幕上的某个地方时键盘会隐藏.我找到了几个文本教程,但我们正在使用搜索栏.
谁能告诉我怎么做?
谢谢.
我有一个奇怪的设置.
我有一个View
名为View1和一个ViewController
调用viewController1
在IB
,View1是ViewController1的子代.
在View1中,我使用代码a创建UITextField
并添加为子视图.
在我Viewcontroller
,我有viewController1 : UIViewController <UITextFieldDelegate>
现在..我想在View1中的文本字段获得键盘中的"完成"按钮时重新签名键盘,所以我有
- (BOOL)textFieldShouldReturn:(UITextField *)TEXTFIELD {
[TEXTFIELD resignFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是,如何在TEXTFIELD(在我的viewcontroller中定义)和我的View中定义的文本字段之间建立连接?
我是否必须在interfaceBuilder中执行某些操作?
也许我完全不在这里......
一些提示非常感谢
我有一个具有用户反馈功能的应用.我已经完成了图像中所示的视图. 我做的反馈意见
我现在要做的是当用户完成编辑textView,然后点击其他地方,如星级或文本视图以外的任何区域,它会将光标隐藏在textview上,但它会同时保留书面文字.
谁能帮我这个?谢谢.
我试图在屏幕上的任何其他地方触摸后隐藏键盘.我正在使用的代码基于这里的答案.
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连接到它.
我有三个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) 我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)
谢谢!
ios ×9
objective-c ×4
uitextfield ×3
iphone ×2
swift ×2
uikeyboard ×2
uitextview ×2
cocoa-touch ×1
hide ×1
html5 ×1
ipad ×1
javascript ×1
jquery ×1
keyboard ×1
searchbar ×1
uikit ×1
uitableview ×1
uiview ×1
xcode ×1