Reputation: 8066
I hope to insert subview in front of displayed keyboard. I am using the following code:
[self.view bringSubviewToFront: myView];
but the subview does not display.
Upvotes: 0
Views: 1540
Reputation: 795
@Altaf, the prefix you mention in your code is not the good one. You should use:
if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES)
See an example, with Touchpose classes to show touches on demo applications, that I modified to display the animation over the keyboard.
Upvotes: 0
Reputation: 6093
Credit to Artyom from this question
Rather than using this for loop to find the correct window you can instead use:
UIWindow * window = [UIApplication sharedApplication].windows.lastObject;
[window addSubview:_menuView];
[window bringSubviewToFront:_menuView];
As long as you are adding it while the is keyboard active then the keyboard will always be the last view added and it reduces the code complexity greatly.
Upvotes: 0
Reputation: 71
I am not exactly sure what you are looking for, but my best guess is you want to subview a "done"/"return" over the keypad. You maybe able to do this by doing something like this (when the keyboard comes up)
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard view found; add the custom button to it
if([[keyboard description] hasPrefix:@"UIKeyboard"] == YES)
[keyboard addSubview:doneButton];
}
The bringSubviewToFront
idea failed because it (the keyboard) is not a subview of your application.
Upvotes: 2