hide keyboard in secondary viewcontrollers when pressing background storyboard - ios

I've been scourging the internet and saw several promising answers but none that worked for me. The problem I have is that I have many ViewControllers that I placed in Storyboard mode.
Lets say in my 5th view controller I have some TextViews and TextFields that pops up a keyboard for user input when pressed. However I want to be able to hide the keyboard when I press the background.
I tried following the first and second responses here: How to dismiss number pad keyboard by tapping anywhere
But I dont think my set up is exactly the same as theirs.
Can someone please help me? Please be VERY SPECIFIC if possible and dont assume I know how to fill in the dots.
Thanks so much!!
edit. sorry for not being clear but I meant I want the app to dismiss the keyboard when the user presses anywhere on the screen (thats not another Text field/view). The link I show does this but my problem is that I am storyboarding so I have multiple UIViewControllers and I'm not sure how to get IBOutlets/IBActions to work for the "secondary" viewcontrollers. They only show up under the first/main one...

In your application delegate file,
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[self.window endEditing:YES];
}

you can use [self.view endEditing:YES];
have a look at the Apple docs for Ending a View Editing Session

Related

Two taps required to make hidden UINavigationBar appear

I have a UITableViewController which contains cells of different languages. When the user taps a cell, they are taken to a UIPageViewController which shows the appropriate leaflet in that language. That part is working well.
I have implemented the use of the following code to make the UINavigationBar hidden and to appear on a tap:
self.navigationController.navigationBar.hidden = YES;
self.navigationController.hidesBarsOnTap = true;
I have that code in my viewDidLoad. I don't have any gesture recognisers, but both on the Simulator and on the device, to get the UINavigationBar to appear, I have to tap the screen twice. Why do I have to tap twice?
If I do the same on a UITableViewController, I only have to tap once, so it seems something specific about this UIPageViewController and I can't quite figure out what.
I've looked around and I can't seem to find anyone with anything similar.
On guidance on this would be appreciated.
Try this :
[self.navigationController setNavigationBarHidden:YES animated:YES];
If that does not work, can you post the code for your methods relevent to this issue?
Could probably help more with more info.

iOS - Automatically Have Keyboard Toggled On ViewController

I have a view in my app where the user has to enter information in a textfield. Instead of them clicking into the text field and toggling the keyboard, I would like to have the textfield already editable with the keyboard preloaded there so the user can immediately start typing. Surprisingly, I couldn't find any resources that preload the keyboard when a view controller is reached.
Any help or advice would be appreciated. Thanks.
in the ViewDidAppear:
[yourTextField becomeFirstResponder];

Helpscreen that will only showup once - UIImageView?

I want to show an UIImage with helpful tips when the user opens my app for the first time. I thought about putting a UIImageView and a button on top of the relevant ViewController and the image will be dismissed with a tap (alpha from 1 to 0) but I'm not sure that it's such a good idea to have a button and an UIImageview on top of my app at all times if it's only going to be used once. I want the image to be on top of the current ViewController so i can point to buttons etc' with arrows.
Is there a more elegant way accomplishing my goal?
And another thing, I want my app to remember that the picture was already shows. Should I use NSUserDefaults for that or is it there another solution I'm not aware of?
Thanks guys
Yes, use NSUserDefaults. Check this in the appDelegate and if not yet shown, show your image. Forget alpha, just present a view controller (modally, popover, however you like) and include a "dismiss" or "close" button that dismisses the view controller.

iOS table disappears

I have a View Controller that have a tableView inside it which has different data in it . when inside the search bar I search for a data in the table, it remove other data and just show the data i was looking for. when i click on the data it push to next view. Everything looks fine but when I go back to the view the tableview will be disappears ! The funny thing in the same app I have other similar view with similar code, but it's ok over there. anyone knows whats wrong with it ?!
in the didSelectRowAtIndexPath i added [mySearchBar resignFirstResponder]; which is my searchbar's textfield and it's ok now , thanks for answers guys

XCode: MasterDetailsView - DetailsView without Splitscreen in Landscape?

actually I'm quite new with Xcode and couldn't find the answer to the following two questions by a google search:
to make it short: I'm working on an iPad app that displays proposals. For this purpose you should choose a proposal from the table in MasterView and then see the details in the DetailsView in landscape mode (but without the MasterView on the Spitscreen).
So when the app starts in landscape mode, I wanna see directly the first proposal full screen on the DetailsView. And when I tap onto the screen the MasterView should popup/unhide with the other proposals in the table. Is this possible?
I wanna display the PDFs in a WebView like in iBooks. That means that the navigation bar is hidden and only when I tap onto the screen the navigation bar should appear at the top of the screen.
I'm kind of sure this questions have been solved somewhere but I couldn't find anything by search so I hope you can help me anyway :-)
Thanks in Advance!
Q1: Use can use one of many methods to present a view (look up under Apple's doc on UIViewController under "Presenting Another View Controller's Content" heading). Two that I have used are: – presentModalViewController:animated: and – presentViewController:animated:completion: (the latter is the latest addition in iOS 5.0)
So let's say you have a detail controller called MyDetailViewController, in your Master View Controller's implementation file (the .m file), under viewDidLoad method, you would do some thing like this to present it as a full screen view.
MyDetailViewController *myDetailViewController = [[MyDetailViewController alloc] initWithNibName:#"MyDetailViewController" bundle:nil];
[myDetailViewController.view setFrame:CGRectMake(0, 0, 1024, 768)]; //might not need this
[self presentViewController:newDetailViewController animated:YES completion:^{
NSLog(#"complete"); //optional
} ];
To dismiss or hide this MyDetailViewController with a tap or touch, you can use UITapGestureRecognizer or touchesEnded method and using one of the dismiss methods (refer back to Apple's UIViewController again for this).
Q2: I personally have not used UIWebView to display PDF and not sure if iBooks is using UIWebview to do it. But to display a varieties of popular documents formats, you can use either the QLPreviewController class or UIDocumentInteractionController. You can hide the toolbar while the document is displayed.
Good luck.

Resources