Objective-c EKEventEditViewController Dismiss keyboard - objective-c

I'm presenting an EKEventEditViewController that I need for inserting an event into the calendar. All is fine, but how do I dismiss programmatically the keyboard when I go picking a date?

I know this is an old post but still didn't answered.I have been in this situation.So,like to share how to do it.
- (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)d {
}
Inside this method you can put [textView resignFirstResponder].This will dismiss keyword while changing date.If you want to dismiss it at the beginning ..just use [textView resignFirstResponder] before calling calendar method .
Hope this will help others.
this is also a nice answer by kirby,you can try this too.
[self.view endEditing:YES];
Courtesy:-https://stackoverflow.com/a/3705527/1865424

Related

How to perform IBAction before dismiss sheetViewController from same UIButton?

I am writing a Cocoa Mac app in Objective-C and using Storyboard for my UI.
I have a "Confirm" button in my sheetViewController.m which I want to perform some action (save some settings) as well as dismiss the sheetViewController at the same time. They both use the sheetViewController.m as outlets.
Unfortunately, with Storyboard, I can only pick one received action (IBAction) or dismissController.
I want to perform the IBAction FIRST, before dismissing the sheet. How can I accomplish this?
Happy to do this in code as well instead of Storyboard if necessary!
Thanks!
You can use codes to dismiss controller in your IBAction.
I found out how to reference Storyboard ID in code:
On MainViewController:
- (IBAction)didClickButton:(NSButton *)sender {
SheetViewController *sheetViewController = [self.storyboard instantiateControllerWithIdentifier:#"SheetViewController"];
// Must match Storyboard ID
[self presentViewControllerAsSheet:sheetViewController];
}
On SheetViewController:
- (IBAction)didClickButton:(NSButton *)button {
// Do something
[self dismissViewController:self];
}

UITableView reloadData causes UITextField to resignFirstResponder

I have a textField that is set to change the tableView's dataSource with each letter that's entered (and call reloadData).
But for some reason, every time a letter is entered, the keyboard is dismissed.
Anyone know why?
Your text field is resigning because reloaded cells are sent a -resignFirstResponder message due to the fact that their survival is not guaranteed after a reload. See this related question for more.
Use this method textFieldShouldReturn: and add UITextFieldDelegate delegate in yourClass.h file. set delegate to yourTextfield and write following code in viewDidLoad method.
yourTextfield.delegate = self;
and also implement the textFieldShouldReturn: as following as
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
[theTextField resignFirstResponder];
return YES;
}
I think it will be helpful to you.

Popover not being dismissed when calling dismissPopoverAnimated or clicking once outside of popover

I hope someone can help me with this weird bug. I've got a popover with buttons to perform various actions. There is a toolbar item that must be clicked to bring up the popover. Here is the action method that is called:
-(IBAction)showActions:(id)sender
{
ActionsPopUpController* controller = [[ActionsPopUpController alloc] initWithDelegate:self state:DELETE_ENABLED | FACEBOOK_ENABLED | TWITTER_ENABLED | EMAIL_ENABLED];
_actionsPopUp = [[UIPopoverController alloc] initWithContentViewController:controller];
[controller release];
[_actionsPopUp presentPopoverFromRect:_actionButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
_actionsPopUp.delegate = self;
}
As you can see, I have a property/ivar (actionsPopUp) that retains a reference to the UIPopoverController. This is used later to call dismissPopoverAnimated when I want to dismiss the popover. Here is an example of it's use:
-(void)shareWishToEmail:(id)sender
{
[_actionsPopUp dismissPopoverAnimated:YES];
[[WishCloudService sharedInstance] showMailer:self withItems:[NSArray arrayWithObject:self.item] delegate:self modal:YES];
}
In this method, I dismiss the popover first, and then perform the action associated with the button that was pressed in the popover. Unfortunately, this doesn't appear to work. The action gets performed, but the popover is not dismissed. In addition, it doesn't seem to get dismissed when the user clicks once outside of the popover. But if clicked outside again, it does get dismissed. Another observation is that the first click seems to hide/dismiss the drop shadow of the popover, but not the popover itself. It's the second click that dismisses the popover. However, no amount of calling dismissPopoverAnimated seems to dismiss the popover at all.
I've swapped in UIPopoverControllers that seem to work in other parts of the application, but get the same results, which leads me to believe that it is something specific to the UIView/UIViewController that I'm presenting the popover in. I am creating the view programmatically rather than through a NIB. It escapes me at the moment why I decided to do that, but I don't believe that it should be relevant. Someone please let me know otherwise. Here is my loadView method:
-(void)loadView
{
self.view = [self createView:_item];
self.currentView = self.view;
_wishItemViews = [[NSMutableDictionary dictionary] retain];
[_wishItemViews setObject:_currentView forKey:[NSNumber numberWithInteger:_currentIndex]];
}
I have a currentView property because I need to be able to slide new views in and out, and I'm using CATransition animations to do it. The currentView property is used to swap the views when it performs the transitions. Again, not sure if this is relevant, but I'm including it for completeness and just in case it does make a difference. Hopefully, that's enough information for someone to help point me in the right direction. Or at least prompt some additional questions that might help me think this through. Any help would be greatly appreciated.
Another observation is that the first click seems to hide/dismiss the drop shadow of the popover, but not the popover itself.
It seems you have stumbled upon the rare double-popover. ;-)

Stop UIPopover from dismissing automatically part II

Sorry I previously posted a question here, but The answers I got didn't work (probably my fault).
Basically, I want to stop a UIPopover from dismissing automatically. I got to this piece of code:
- (BOOL) popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
return NO;
}
which I put in, but it doesn't seem to have any effect. Is there anything else I should add?
am I putting it in the right place (I was putting it in the vc.m of the view that has the popover within it)?
Thanks Very Much,
Luke
Check to make sure the UIPopover delegate is set. You can do this in code by setting the popover instance variable:
aPopover.delegate = self;

Keyboard not show onload

I want the keyboad show automatically onload, but it did not work as i expect
here is the code i use:
- (void)viewDidLoad {
[super viewDidLoad];
[seachBar2 setDelegate:self];
}
- (BOOL)Searchbar2ShouldReturn:(UISearchBar *)searchBar2 {
[searchBar2 becomeFirstResponder];
return YES;
}
Coud somebody will point me how to fix this
thank you somuch
- (void)viewDidLoad {
[super viewDidLoad];
[seachBar2 setDelegate:self];
[seachBar2 becomeFirstResponder];
}
Just came across this, and it helped but the answers are vague.
All you need to do now in iOS 5 is make an outlet connection to your object (for example a UITextField) and then in viewDidLoad method type;
[myTextField becomeFirstResponder];
or for your search bar
[searchBar2 becomeFirstResponder];
Make sure searchBar2 in your code points (IBOutlet) to the searchBar in the Interaface Builder.
in your code:
IBOutlet UISearchBar *searchBar2;
In IB:
goto the search bar's Connections Inspector (apple-2) and drag the Referencing Outlet to File Owner and select searchBar2
Hope this helps.
You do need to override viewDidAppear:, and verify it's actually being called (put a breakpoint or an NSLog() statement in there). You should also determine the language you're coding in (it's Objective C).
Your -Searchbar2ShouldReturn: method will never be called by the system. I think you may need to go back and work through a few of Apple's tutorials here; your grasp of the frameworks seems tenuous, at best.