When presenting a UIPopoverController from a UIButton the entire screen behind the popover is dimmed.
Is it possible in some way or another to prevent the presenting button (the one pressed to show the popover) from being dimmed?
I remember solving this problem when it has appeared the first time on iOS 7. The only solution (if nothing has changed) has 3 parts:
Remove the default background (setting popoverBackgroundViewClass).
Add your own background (I used a subclass of UIPopoverController to handle the appearance callbacks)
Display your button (or any other passthrough views) above the background. You can either remove them from their hierarchy and move them to the same position in the background or just take a screenshot of them and add them to the background.
In the end it's not too difficult but it takes time to debug.
Related
Here is a transitioning animation of UINavigationBar used in Facebook for iOS:
The topViewController is being changed, but the titleView is transitioning seamlessly.
(For your information, the two textfields are the same instance (checked with FLEX). However, I don’t care if the two textfields are not the same instance.)
What's the best way of approaching this?
Thanking you in anticipation.
I'm fairly confident that is not a navigation push/pop. I suspect what they're doing is hiding the left bar button to make the search field larger, and then just adding a view on top of the current VC's view. When you cancel, they hide the view and show the bar button. The clues I'm using to draw this conclusion are that (a) I've been writing iphone apps for years and I have no idea how to make a nav controller/bar do what you want with a push/pop, at least not without a lot of faking it and hoop jumping, (b) you video has the new view "pushing" from the wrong side, and (c) in my copy of the FB app, there is a different animation where the second view just appears/disappears without any push/pop animation.
I wanted to display a Popup view on top of the screen but while enabling the actual screen as well. User should be able to perform all touch actions on the screen's controller while displaying and allowing touch actions on popup view as well. No fade for background ofcourse.
I do not see a existing style for UIAlertController that meets this need.
Is it possible with UIAlertController?
(PS. with UIPopoverPresentationController Custom style, managed to disable fade but still couldn't get the touch controls work on background screen)
Sounds like you might want to look into passthroughViews property on UIPopoverPresentationController. From the documentation:
"When displayed, taps outside of the popover window cause the popover to be dismissed automatically. To allow the user to interact with the specified views and not dismiss the popover, you can assign one or more views to the passthroughViews property."
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPopoverController_class/
I need to create below thing
Currently i'm using WYPopover , but I can't create the button since it's outside of the popover. Is there any existing solution out there ? Many thanks
Create a bigger popover UIView holding all your child elements (current popover + button) and make its background transparent or however you wish.
Popover-controller's are exclusively used in iPad. If you want to use in iPhone, you should create it in a custom way.
I am not familiar with the XYPopover in Github, but normally the custom created popover should be dismissed whenever the user taps any place in the screen. That is one of the key feature of the popovers.
Normally the custom popovers are build like, adding a hidden parent view and then the visible image of a popover frame on it.
You should to do the following,
Avoid dismissing the parent view on tap of parent-hidden-view.
Add a close button at the area where you want to show the close button, on top of the parent-hidden-view.
Capture the button click and dismiss the view (remove the view from superview)
How to customize your need
Creating custom popover view is not a big task. It will take maxim one day, try it your self.
One Parent view with clear color
One background image of a popover frame.
View-inside popover (this needs to be customized for UIPopover also).
Close button.
Have you used Tinder app?
That app is full of nice effects that makes a great UX experience in my opinion.
Try to open it and you see the launch image with a red flame at the center of the screen.
Seconds after the flame moves itself to the navigation bar to make the app logo.
The animation I am trying to create it exactly that and I can't figured out how to (1) let the navigation bar appear in that way and (2) to transition a custom UIView inside another view.
If I'd find an app to record the screen of my iPhone I will post a video explaining the animation I'm referring to.
In the meanwhile, do you have any ideas?
The animation I am trying to create it exactly that and I can't
figured out how to (1) let the navigation bar appear in that way and
(2) to transition a custom UIView inside another view.
Animation's are often not exactly what they seem to be. For example, when you segue from one view controller to another the animation you see often uses images instead of transforming the actual views.
You can do the same kind of thing for the animation you want. You don't have to actually move a view from one view controller to another -- just create the appearance that you did:
Create an animation that moves the image in question (like the flame) into position on top of the navigation bar.
Set the titleView of the destination view controller's navigation item to include the same image in the same location.
Remove the animated image. The user won't notice a change because the same image is already present at that location.
Have a legacy UISplitViewController iPad app that displays a modal view from the "right side" VC pane using presentViewController:animated:completion: with the modalPresentationStyle set to UIModalPresentationFormSheet. In viewDidAppear of the modal view's VC, we call becomeFirstResponder on a UITextField. In iOS6, this results in a centered modal view sliding up from the bottom which then focuses the KB. However, since iOS7, what occurs is after the view slides up from the bottom, it slides to the right by about (estimating) 200 points. Weird thing is, if you dismiss the keyboard, as soon as you do, the view slides back to it's centered position like it is on iOS6. From then on, while the modal view is up, KB focus causes it to stay centered and only slide up a little, which is normal iOS behavior for non full screen modal views. It's like once you dismiss the KB once it "corrects" itself from then on. I have experimented and found that:
If you set animated to NO for the presentViewController call it works like iOS6.
If you don't call becomeFirstResponder at all, it works like iOS6.
If you call performSelector:xxxxafterDelay:0, passing becomeFirstResponder as the selector instead of calling becomeFirstResponder directly, it also works like iOS6.
Option 3 from above is currently my go forward workaround, but my question is: is this an iOS7 bug, or are we doing the wrong thing that was obviously ok in 6 but not in iOS7?
Only occurs post-iOS7. Only recreated once on simulator, but 100% of time on test device (iPad mini). From the searches I've done my current best guess (assuming our code isn't to blame post-iOS7) is there's a race condition type bug between the animations of the keyboard and the view sliding up from the bottom in the iOS UI layer that causes the view to shift right instead of up, like it normally does when a non full screen view is presented modally and the KB is popped. I got that theory after reading this similar SO question.
Had this problem. This is definitely a bug in iOS7.X. (You should open a bug report with Apple!). What happens is Apple has bug in its layout calculation and shifts the modally presented view.
We used
dispatch_async(dispatch_get_main_queue(), ^{ [view becomeFirstResponder]; });
to overcome the issue, which is similar to your #3. This delays the keyboard appearance until after the view's layout, overcoming the issue.