1

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

got2jam
  • 515
  • 5
  • 16
  • If I remember correctly, the class is a generated by iOS to have a read-only `textField`, so setting it's `editable` state to `NO` is likely not going to do anything helpful. I suppose you could attempt to `resignFirstResponder` when the extension is support to first pop up. But there's a chance that subclassing `UIViewController` and creating your own custom view controller is going to be the easiest route if you dont want to use the out-of-the-box solution that's provided with `SLComposeServiceViewController` – Louis Tur Nov 25 '15 at 23:09

1 Answers1

4

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];
}
Esti M
  • 193
  • 2
  • 10