Can not Hide Keyboard with SLComposeServiceViewController

青春壹個敷衍的年華 提交于 2019-12-13 02:01:10

问题


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;
}

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;
}

And just for fun

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

    return NO;
}

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

What could be happening?

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


回答1:


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];
}


来源:https://stackoverflow.com/questions/33925023/can-not-hide-keyboard-with-slcomposeserviceviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!