Laurent Crivello
Laurent Crivello

Reputation: 3931

inputAccessoryView dismissed when UIAlertController displayed

For an iOS app, I have an UIViewController with an UITextView that uses an inputAccessoryView to keep a view docked to the bottom of the screen (or top of keyboard).

However when I display an UIAlertController, the inputAccessoryView disappears.

 UIAlertController * view =[[UIAlertController alloc]init];
 <Add menuItems>
 [self presentViewController:view animated:YES completion:nil]; <-- inputAccessoryView disappears

I found some stackOverFlow articles that explain how to work around this, but not only they are in Swift, but even translated in Objective-C, it does not work:

UIViewController *objViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[objViewController presentViewController:view animated:YES completion:nil];

How can I keep my input AccessoryView displayed ?

Upvotes: 1

Views: 339

Answers (1)

Laurent Crivello
Laurent Crivello

Reputation: 3931

Found it by properly translating the Swift answer indicated in the referenced article:

UIViewController *objViewController = [UIApplication sharedApplication].windows.lastObject.rootViewController;
[objViewController presentViewController:view animated:YES completion:nil];

Upvotes: 2

Related Questions