uipopover hides when keyboard shows - ios5

i have an UIpopover with UItextfield in it, when i open popover and tap on uitextfield then keyboard shows, but it hide the popover. How can i show keyboard without hiding UIpopover?
i am calling popover in UIWebView because i use cordova 1.8.1, but i tried it in UIView too, and it hides too.
here code of calling UIpopover :
if (popEl==nil){
popEl=[[Popover alloc] init];
}
if (pcs==nil){
pcs=[[UIPopoverController alloc] initWithContentViewController:popEl];
pcs.delegate=self;
}
[pcs presentPopoverFromRect:CGRectMake(0, 0, 1, 1) inView:self.webView permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
P.S. Sorry for my English, i am from Ukraine.

firstly i recommend you to go through the apple documentation of UIPopOverController
for your problem i think you have to deal with the appearance and disappearance of Keyboard here's the solution to handle this problem Check it

Your question is that, when U click on the textField the pop over view should appear,right? if yes, then add this code before you add the popoverview,
[textField resignFirstResponder];

Related

is it possible to disable keyboad(UITextField) without hidding?

I'd like to disable UITextField's keyboard without hidding.
is it possible?
If it's so, could you show me how to do?
thanx
Carsh
if you implement delegate method of uitextfield
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return NO;
}
It does not show the keyboard.
I don't believe the UIKeyboard can be disabled without hiding it.
If you'd like to disable user interaction with the keyboard, you could add an extra UIWindow on top of your existing windows.
By overlaying the UIKeyboard with a transparent UIWindow, the user would be able to see the keyboard, without interacting with it.
a haha , i have a very very ugly method. you can creat a view whichs frame = the keyboards frame. [view setBackgroundColor:[UIColor clearColor]]; [self addSubviews:view];
I did not try but this should work:
textField.inputView.userInteractionEnabled = NO;

How do I launch a modal view from a custom UITabBar?

I've built out the raised-center UITabBar from this GitHub location.
My challenge now is that I can't figure out how to create a modal view that will appear when the button is pressed.
Has anyone used the idev-recipes RaisedCenterTabBar with luck? How did you implement the modal sheet that appears there?
Alternatively, is there a different gitHub project that has a working custom tab bar with a modal sheet?
Thank you!
Here was my solution, it was BY FAR the cleanest way I found to do this... I really hope it helps, I spent hours researching the best ways.
I setup a "UITabBarController" delegate that connects directly to my tab interface built out on my storyboard.
** Don't forget to include the "tabBarController" delegate in your header file
** Notice this callback method is NOT the "didSelectViewController" but rather the "shouldSelectViewController". This method handles the request before the tab is selected and that is exactly what you want so you can STOP the request before it ever happens... This way you don't have to save the current index you are on, pass it around and all that nonsense.
Then I am simply checking what tab WILL be selected (based on the view controller's title.
** Also: this is my code, change it as needed for your code. But the principals should remain. My "performSegueWithIdentifier" is actually a manual segue connected to my tab controller that opens in a modal. This code is working brilliant for me.
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
if([[viewController title] isEqualToString:#"tellvc"])
{
[self performSegueWithIdentifier:#"shareModelViewController" sender:Nil];
return NO;
}
else
{
return YES;
}
}
I have something similar in a program of mine that I'm working on and would be glad to show you how I do it. I have a couple of viewControllers in a TabBar. I create my Plus button in whichever VC I decide will appear first on the screen in ViewDidLoad.
// Create a plus button that appears on the tabBar
UIImage *plusButton = [UIImage imageNamed:#"plusbutton.png"];
UIView *tabBarView = [[self tabBarController] view];
addButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addButton setFrame:CGRectMake(127.0, 432.0, [plusButton size].width, [plusButton size].height)];
[addButton setBackgroundImage:plusButton forState:UIControlStateNormal];
[tabBarView addSubview:addButton];
[addButton addTarget:self action:#selector(scalePicker:) forControlEvents:UIControlEventTouchUpInside];
I make the button a subView of the tabBarController's view. Later on in the implementation of this VC I have a method called scalePicker: which creates and instance of one of my other VC's and presents it modally. Here is the code for that: (note: this is the method that I set as a target for the plus button in the code above)
-(void) scalePicker:(id)sender
{
// create the view scalePicker, set it's title and place it on the top of the view hierarchy
sp = [[ScalePickerVC alloc] init];
[self presentModalViewController:pickerNavController animated:YES];
}
I hope this helps you,
Good Luck!

MFMailComposeViewController Keyboard Issue

How do i dismiss the keyboard without pressing the Send or Cancel button in MFMailComposeViewController?!
Thanks for any help.
Can you try this.
UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView* firstResponder = [keyWindow performSelector:#selector(firstResponder)];
[firstResponder resignFirstResponder];
hope this helps....
I experienced a similar problem: For some reason iOS does not dismiss the Keyboard of a MFMailComposeViewController when the application enters background (the dismiss happens when the application becomes active again). However iOS dismisses the keyboard if the first responder is a simple element (e.g. textview). Calling resignFirstResponder did not work for me in this particular case.
Because I switch windows on applicationBecomeActive (to show a login screen) I ended up having multiple keyboards above each other (the one on the top not working).
I found a simple workaround to dismiss the keyboard of an MFMailComposeViewController when the application resigns active:
- (void)applicationWillResignActive:(UIApplication *)application
{
// Workaround: MFMailComposeViewController does not dismiss keyboard when application enters background
UITextView *dummyTextView = [[UITextView alloc] init];
[self.window.rootViewController.presentedViewController.view addSubview:dummyTextView];
[dummyTextView becomeFirstResponder];
[dummyTextView resignFirstResponder];
[dummyTextView removeFromSuperview];
// End of workaround
}
This will implicitly resign the first responder if we have any viewController that is currently beeing presented.
While you probably can do it by finding whichever view is the first responder and calling resignFirstResponder on it (unless you're on iPad and MFMailComposeViewController uses UIModalPresentationFormSheet), Apple might reject your app for it. Quoth the documentation:
Important: The mail composition interface itself is not customizable and must not be modified by your application.
This could easily be construed to include the behavior of the keyboard.

How to add a HUD? (iOS)

I am trying to have some controls appear when you push a button and have it disappear when you press a different button. Right now the HUD is comprised of an image view, and some custom buttons in a UIView called "credits". I've managed to have it disappear using:
[credits removeFromSuperview];
How do I have it reappear?
If it's just a UIImageView, you should...
[self.view addSubview:credits];
... assuming you've not released it already. On a side note, there is a really good HUD for iOS here: http://github.com/matej/MBProgressHUD
I believe you can just set the view to be hidden
[self.view setHidden:YES];
While it's hidden, you can also update the view and then show again
[self.view setHidden:NO];
You'd better set their hidden property to whether YES or NO
This method will toggle the UIView credits hidden property
- (void) toggleCredits {
[credits setHidden:![credits isHidden]];
}

Keyboard won't dismiss when popover closes on iOS 3.2

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
[self dismissFirstResponder];
return YES;
}
-(void)dismissFirstResponder {
[nameField resignFirstResponder];
[descriptionField resignFirstResponder];
[helpField resignFirstResponder];
}
I have tried loads of different things, but the keyboard just isn't going down:
I checked to see if my outlets were hooked up correctly in Interface Builder
I put breakpoints inside the 2 methods to check they were being called at the appropriate times, and they were. Those 3 Text Fields are the only ones in the app.
What happens: The popover gets dismissed but the keyboard stays up.
I would really appreciate some help on this matter. It might be a known bug on iOS 3.2, if so any workarounds would be gratefully accepted. Thanks
Make sure the delegate for UITextView the UITextField is assigned
Then call the following method to dismiss any keyboard activity from the view.
[self.view endEditing:YES];