无法使用SLComposeServiceViewController隐藏键盘 [英] Can not Hide Keyboard with SLComposeServiceViewController

查看:167
本文介绍了无法使用SLComposeServiceViewController隐藏键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的共享扩展名"除了需要在表视图中进行配置外,不需要任何用户输入,因此当我在Safari中显示该视图时,我试图隐藏键盘.我可以在模拟器中很好地运行代码,但是当我在设备上进行测试时,我发现Share Extension无法启动并且Safari挂起.

My Share Extension doesn't require any user input aside from configuration in a table view so I am trying to hide the keyboard when the view is presented in Safari. I'm able to run my code in the simulator fine but when I test on my device, I'm the Share Extension doesn't launch and Safari hangs.

我尝试了几种防止键盘启动的方法

I've tried a few ways to prevent the keyboard from launching

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.textView.text = @"\n Place Holder Text";
    self.textView.editable = NO;
}

同样,我在loadView中尝试了它,因为那是SLComposeServiceViewController所在的位置 设置textView和textView委托.

As well, I tried it in loadView since that is where SLComposeServiceViewController sets the textView and the textView delegate.

-(void)loadView{
    [super viewWillAppear:animated];
    self.textView.text = @"\n Place Holder Text";
    self.textView.editable = NO;
}

只是为了娱乐

-(BOOL)textViewShouldBeginEditing:(UITextView *)textView{

    return NO;
}

所有这些功能都可以在Simulator上运行,但不能在我的设备上运行.

All of these work on the Simulator but not on my device.

可能会发生什么?

我是否缺少某种通知或观察者(或Safari)

Is there some kind of Notification or Observer that I'm (or Safari is) missing

推荐答案

您只需要将代码放入"viewDidAppear"函数中即可. 对我来说很好.

You just need to put your code in "viewDidAppear" function. It works fine for me.

-(void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.textView setText:@" Place Holder Text"];
    [self.textView setEditable: NO];
}

这篇关于无法使用SLComposeServiceViewController隐藏键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆