- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已添加 InputAccessoryView
到我的键盘消失。它炒得很好。但在某些 ViewController
它没有出现。即使那个方法也不会调用。
我有一个按钮。当我点击我的文本字段时,它会自动成为第一响应者。 (单击该按钮时光标聚焦在文本字段上)键盘来了,但输入附件 View 没有来。
我正在 iOS 8.2 设备上对此进行测试。
这是我的代码
在 viewDidload
// for search------------------
UIView *srchPadView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 30)];
[srchtextbox setLeftView:srchPadView];
[srchtextbox setLeftViewMode:UITextFieldViewModeAlways];
srchtextbox.attributedPlaceholder=[[NSAttributedString alloc] initWithString:alertStrings.strSearch attributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:1 green:1 blue:1 alpha:0.6]}];
[srchtextbox setTextColor:[UIColor whiteColor]];
srchtextbox.delegate=self;
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(textFieldTextDidChangeOneCI:)
name:UITextFieldTextDidChangeNotification
object:srchtextbox];
-(void)textFieldTextDidChangeOneCI:(NSNotification *)notification
{
isSearching=YES;
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(getSongs)
object:nil];
loading=YES;
[mainactivityindicator startAnimating];
songsArray=[[NSMutableArray alloc]init];
songstable.hidden=YES;
startRec=0;
[self performSelectorInBackground:@selector(getSongs) withObject:nil];
}
- (UIView *)inputAccessoryView {
if (!inputAccessoryView) {
CGRect accessFrame = CGRectMake(0.0, 0.0, 320, 40);
inputAccessoryView = [[UIView alloc] initWithFrame:accessFrame];
inputAccessoryView.backgroundColor = [UIColor colorWithRed:70.0/255 green:70.0/255.0 blue:70.0/255.0 alpha:0.9];
UIView *line=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 1)];
[line setBackgroundColor:[UIColor colorWithRed:134.0/255.0 green:139.0/255.0 blue:143.0/255.0 alpha:1.0]];
[inputAccessoryView addSubview:line];
UIButton *compButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
compButton.frame = CGRectMake(260.0, 2, 60, 37.0);
[compButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
[compButton setTitle: @"Done" forState:UIControlStateNormal];
[compButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[compButton addTarget:self action:@selector(completeCurrentWord:)
forControlEvents:UIControlEventTouchUpInside];
[inputAccessoryView addSubview:compButton];
}
return inputAccessoryView;
}
-(IBAction)completeCurrentWord:(id)sender{
[self.view endEditing:YES];
inputAccessoryView
从不打电话。这是为什么。我怎么解决这个问题?请帮我。
最佳答案
你需要
inputAccessoryView
并返回您的 View 。 -(BOOL)canBecomeFirstResponder{
return YES;
}
[self becomeFirstResponder];
当您需要输入附件 View 可见时
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
关于ios - inputAccessoryView 出现键盘时不调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30164233/
我正在尝试在 SwiftUI 中的 TextField 上实现一个 inputAccessoryView。目标是在键盘上方出现一个“完成”按钮,按下该按钮时会摆脱键盘(即 resignFirstRes
我已添加 InputAccessoryView到我的键盘消失。它炒得很好。但在某些 ViewController它没有出现。即使那个方法也不会调用。 我有一个按钮。当我点击我的文本字段时,它会自动成为
自从我升级到 Xcode 5.1 后,我的 inputAccessoryView 出现了问题。 如您在附图中所见,按键在 inputAccessoryView 内的工具栏后面弹出。我认为它与新版本的
我正在为 UITextField 和 UIToolbar 设置一个 datepicker 来代替键盘。我希望能够关闭 accessoryView,但它没有正常运行。虽然我按下了 Done 按钮,但没有
我有一个 Objective-C 项目,我想在其中添加一个 inputAccessoryView 到 UITextView 的子类。老办法是 self.myTextView.inputAccessor
我已经看过了this solution .我已经创建了一个显示错误的示例项目。 该 View 只有一个 UITextField。 这是我的代码: class ViewController: UIVie
Problem relates to this.我正在尝试使用我制作的自定义 View ,它有两个 TextField 输入和一个按钮,我使用 IB 它的 xib 制作它,我将它放在我的 Storyb
今天早上,我正在查看我在某个地方找到的一些旧代码(并在应用程序中使用),这些代码破解了 UIAlertView 以便从用户那里获取一串输入。出于这个目的,它有点矫枉过正,看起来很傻,但我从未见过更简单
我正在尝试复制 Facebook Messenger 应用程序,其中有一个 UITextView 附加到键盘顶部。 由于此应用的性质,我需要附加我的 View ,而不是在出现键盘时手动上下滚动Scro
是否可以在键盘上方创建 inputAccessoryView,用于拆分模式下的屏幕全宽?系统会自动调整其大小以适合应用程序框架。这是 iOS 中的错误吗? 最佳答案 您可以使用此方法检测您的键盘是否处
知道如何让 inputAccessoryView 锚定到标签栏而不是屏幕底部吗? 我创建了一个 UIViewController 并覆盖了以下方法: -(BOOL)canBecomeFirstResp
我正在尝试创建一个类似于 iOS 消息传递应用程序的消息传递界面。我正在努力解决的部分是覆盖 inputAccessoryView(在 View Controller 上)对我没有影响。 如果您查看下
我正在尝试添加带有“完成”按钮的 UIView 作为文本字段的输入附件 View 。 let view = UIView() let doneButton = UIBu
UISearchBar 似乎将 inputAccessoryView 作为 readOnly 属性。如何使用我自己的 customToolbar 进行设置? 最佳答案 编辑:如以下评论中所述,这不再是
我在 textView 的 inputAccessoryView 属性中使用工具栏。当键盘显示时,它会按预期显示工具栏。旋转设备时,我想删除工具栏。我试过: myTextView.inputAcce
我正在尝试实现与 Apple 消息应用中底部文本输入栏类似的定位行为。 我尝试了很多方法,到处搜索,有很多类似的问题,但没有一个是令人满意的。 要指定: 在 View 底部有一个UIToolbar 工
我已经为我的应用程序中的某些 UITextFields 添加了一个 inputAccessoryView 到 iOS 键盘。这个附件 View 为用户提供了基本功能(一些按钮在我的应用程序的其他地方没
我正在以模态方式呈现一个 UIViewController,该 View 包含各种 UITextFields。我已经重写了模态视图 InputAccessoryView,以便它显示一个简单的 View
全部, 我的 UITextView 上附加了一个可滚动的 InputAccessoryView。创建如下: 创建一个 UIScrollView 添加一个水平 UIStackView。 将堆栈 View
我有一个简单的 UIViewController,其中包含一些对象:一个 UITextView 和一个作为 InputAccessoryView 添加到 UTextView 的 UIToolBar。当
我是一名优秀的程序员,十分优秀!