IOS - Prevent page curl in PageViewController - ios5

I have a UIPageViewController that displays images. I've set an opportunity to mail a desired image that the user is currently viewing. For this if user taps once the central region of the screen a tab bar appears with a bar button item titled "Mail". And when this button is pressed the imaged is attached to a mail composer. But I have a little problem here: As the bar button is on the left edge when I tap it page curl takes place and I can't get the mail composer-more precisely I can't get the button tapped. How would I prevent page curl when this button is pressed?

There are several ways you can overcome this problem. The second solution is easier to implement.
The first one is to access the gesture recognizers defined for the page view controller (from the "gestureRecognizers" property, which returns an array of gesture recognizers), search for the "tap type" gestures and then assign them a delegate to your view controller. This delegate will implement the method gestureRecognizer:shouldReceiveTouch: and will check if the tap occurred in the tab bar position and will return NO in such case, so the gesture will not be triggered. Your delegate will return YES if you still want the tap but it is outside the tab bar region.
Another possibility is to define a new tap gesture recognizer and assign it to the tab bar. In such case when you tap over the button (which is in the tab bar) the target selector that you assigned to your tap gesture will be triggered. Clearly, this selector will do nothing as its purpose is just to avoid propagation to the gestures which are beyond it (this is the default behavior).
I think my answer came too late from your request, so if you have found a better solution please post it!

Related

Swift disable touchesEnded

I am trying to disable the TouchesEnded event in my Code when someone clicks on a button. And when the user clicks on another button the TouchesEnded should be activated again.
So for understanding what my app does, every time you click on the screen the text on the screen changes. But when the user clicks the Button a, this touch event should be disabled. And when the user clicks on button b it should be activated again.
i have already tried self.view.isUserInteractionEnabled = false , but then I am not able to click on the button to activate the userInteraction again.
Does anybody as an idea how to fix this problem?
From the behavior you're describing, I'm assuming that your button is a subview of the view that's toggling isUserInteractionEnabled? Setting that flag to false will prevent user interaction on the view's subviews as well. You can fix this by adjusting the view hierarchy so that your button and your self.view are siblings: aka create a container view that has both the button and your referenced self.view as children.
It doesn't make sense to "disable the TouchesEnded event".
You need to enable or disable your buttons and let the events be sent as normal. Alternatively, as you say, you could use isUserInteractionEnabled=false to make a button no longer respond to taps.
Edit:
After rereading your post, I think I understand what you are saying:
"every time you click on the screen the text on the screen changes" - this means clicking anywhere but on the buttons.
"But when the user clicks the Button a, this touch event should be disabled. And when the user clicks on button b it should be activated again."
So you want button clicks to disable/enable taps elsewhere on the screen.
I would suggest using a tap gesture recognizer (UITapGestureRecognizer) attached to the content view for your view controller. Those trigger an action when they fire, and have an isEnabled property. If you set that to false the tap gesture recognizer will stop responding to taps.

Buttons of one particular view controller are not working

On tapping one button of first view controller, I am navigating to second view controller with performSegueWithIdentifier(identifier is given in storyboard and working fine).Second view controller will be shown in Landscape mode.
In second view controller there is a mapView(google). below the map, there is one button; on top of the map there is one more button, but both the button actions are not working.
userInteractionEnabled, enabled , accessibility all are correct.
Action methods are also dragged from storyboards properly and have been properly connected.(Removed and even connected again also)
Still action methods are not getting called. Buttons are also not clickable there.
Couldn't find the reason. thanks for help.

Tool bar button items not responding when searchDisplayController is active on ios7

My application has searchDisplay Controller and a tool bar with Bar button items on it.My problem is that when i tap search button ,search results are shown but my Bar button doesn't respond to click event on ios 7.But the same thing works fine for ios 6.
Bar button works fine when i tap without searching.I understand that bar button is not reactive when my searchDisplay Controller is set active.
I am unable to find the reason and need to over come the issue.
It's not working as your SearchDisplayController is handling the touch event and as such doesn't pass it through the responder chain, down to the bar view.
You can manually pass the event through so that your bar responds to the touch if required.
Check this out: What's the trick to pass an event to the next responder in the responder chain?

Where should I "save" changes in my iPhone view to 'create new' of an object?

I have a view that creates a new core data managed object, and fills in all the required properties and also allows optional ones. I originally had a "Done" button on the top left, and when that was pressed, I validated the object then saved and removed the view.
Now I have an edit/done type setup on the top right, so sometimes there are two identical "Done" buttons on the top of the view. I want to switch the left side button so that it just has the normal "Back" button, then somehow validate and stop the view from being removed if it doesn't validate. I can't find any way to capture the method called by that back button and modify it, and viewWillDisappear doesn't work cause there's no way to abort the disappearing.
How can I make this work? I need to validate this, then save, then remove the view if validate and save worked only.
It sounds like your view is a perfect candidate to be pushed modally instead of through the navigation controller stack.
Push the view that creates your NSManagedObject modally:
[self presentModalViewController:yourViewController animated:YES]
Then continue to use your top right EDIT/DONE button for editing/validation as you currently are and when validation is successful simply save your object and dismiss the modal view controller from the parent view controller:
[[self parentViewController] dismissModalViewControllerAnimated:YES];
For more details check http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14
If you still want to use a button on the left hand side perhaps you can change the right button to say EDIT/CANCEL and add a DONE button on the left side that is only visible when you're not in EDIT mode. If appropriate you can point the DONE button to run through the same validation process before dismissing the modal view using the code above but it probably makes sense that the EDIT/CANCEL button takes care of it.
I hope this helps.
Rog
There is no documented way to intercept the standard back button of UINavigationController. If you want this functionality, your only option would be to customize leftBarButtonItem with a custom button.
When the user taps that button, you can first validate your object and then call popViewControllerAnimated:.
It's hard to mimic the look of the built-in back button, though.

How can I dismiss the view appeared by touching Add item in UINavigationController?

I have added add(+ symbol button) button to my navigation controller.
When I click it a view appears from bottom. I added a navigation bar and two buttons to it.
One save and one cancel button. And the view have one textEdit box. After editing I can save or cancel. If I touch cancel I need the view to disappear like it should go down again.
I think all iPhone , iPodTouch users use it. Like when they touch Add item then a view appears from bottom and when they cancel it goes down again. How can I make in this way in my application.
Maybe you're talking about a UIActionSheet?!?
http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIActionSheet_Class/Reference/Reference.html