Does anybody has an idea about how could I dismiss a popover before orientation change on iOS 6.
I've tried the following:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:NO];
}
}
But it is not working for me. The popover is still there after the rotation.
- (BOOL) shouldAutoRotate
is not called in my viewController cause it's in a SplitViewController and NavController.
I've read that I can subclass from this containers to forward the shouldAutorotate, but I don't want to do this because of different reasons.
I don't want to dismiss popover after orientationchange (in didRotateFrom...), because it's ugly.
Do you have an idea, how could I dismiss the popover before orientation change on iOS 6?
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(deviceOrientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
This will do it once the rotation did change then you can do what you want in the device orientation. Otherwise you need to listen on the view controllers and send the message there.
try this
- (void)viewDidLayoutSubviews
{
[popOverController dismissPopoverAnimated:YES];
}
Related
I know it's possible to disable the scene gesture when pushing the scene with a sceneconfig where gestures are null like so:
return {
...CustomNavigatorSceneConfigs.FloatFromBottom,
gestures: {}
};
But I'd like to temporarily disable the gesture when the view is already pushed.
I have a lightbox/image modal with zoom support. When the image is zoomed-in I need to disable the swipe gesture as it will otherwise activate when the user is panning the image. But by default and zoomed-out I want the gesture to work.
Is it possible to disable the sceneconfig gesture on the fly - like in response to the current state?
My workaround right now is to handle the gesture logic inside the view instead (with panresponder/scrollview events) but since navigator routes aren't transparent (#4494) it's not possible to replicate the default animation/gesture this way.
I have a problem with Bootstrap-UI Tooltip/Popover-directive in mobile displays.
If the User clicks a button with a Tooltip, this Popover is shown correctly. But unfortunately this popup will not close if the user clicks somewhere else.
Does everyone had the same problem and found a solution for this?
I use the latest version (0.12.1).
Add onclick="void(0)" behavior to some of your background elements which when tapped will get rid of the popovers.
credits: https://github.com/angular-ui/bootstrap/issues/2123
The default triggerMap for the tooltip looks like so:
var triggerMap = {
'mouseenter': 'mouseleave',
'click': 'click',
'focus': 'blur'
};
The mouseenter show trigger has a dismiss trigger of mouseleave. You can try creating your own trigger and adding a blur dismiss trigger like so:
'mouseenter': 'mouseleave blur'
I've had the most success using CSS to allow iOS to detect the "body" (and any nested element that would bubble down) as a clickable element and therefor trigger a "click" event, like you'd expect on a desktop device.
This media query will target touch devices, and not cause a cursor style change on desktop devices. It solves for both Tooltips and Popovers, including tooltips that use mouseenter or outsideClick.
#media (hover: none), (pointer: coarse) {
body {
cursor: pointer;
}
}
I wasn't having issues in Android on Chrome, but the above will fix it for Mobile iOS on Safari or Chrome.
so I created my own custom layouts for my UICollectionView. When i rotate from portrait to landscape mode, some of the cells start to reload its content. I thought the layout just changes the positions of every cell not reload the content?
The content should only reload when i call reload Data on the collection view.
Any ideas to what might be going on?
Use invalidateLayout instead of reloadData on rotation, or override shouldInvalidateLayoutForBoundsChange: and return YES in your UICollectionViewLayout subclass.
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
myCollectionView.frame = self.view.bounds;
[myCollectionView.collectionViewLayout invalidateLayout];
}
Not sure if you are aiming for this, but here it goes:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self.collectionView reloadData];
}
I have a setup where an iPad app supports all orientations. In part of the application, a tap triggers the display of a modal view controller which requires a navigation controller. So I'm basically doing:
UIViewController *myViewController = [[UIViewController alloc] initWithNibName:#"MyView" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:myViewController];
NSLog(#"%d", nav.interfaceOrientation);
[window.rootViewController presentModalViewController:nav animated:YES];
This works fine when the iPad is in portrait (home button). In any other orientation, the modal view always appears in portrait from the home button rather than the current bottom of the device.
If I skip the navigation controller completely and just show myViewController modally, it appears correctly.
So, I tried subclassing the UINavigationViewController and explicitly overriding the shouldAutorotate: and supportedInterfaceOrientations: methods, but this doesn't have any effect. Interestingly if I override the viewWillAppear method and log the value of the interfaceOrientation property, this always returns 1 even if it returns the correct value when accessing it from the code above.
I've also checked that all orientations are supported in Info.plist.
So, what else could be happening to cause this behaviour? Any help greatly appreciated.
Try to implement preferredInterfaceOrientationForPresentation in your subclass of the navigation controller.
The following worked for me:
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return self.interfaceOrientation;
}
I want to display a modal view but I have two problems:
There is no presentModalViewController in iOS 6 and I have to use presentViewController which is just display my second ViewController like a modal segue not a modal window without full screen option,
My second problem is how can I show the modal window from UICollectionViewController. I tried to use presentViewController but it just works with ViewController not CollectionViewController.
The best example of what I want to do is this (Instagram). How they made this modal window? Is it because it's still working with older iOS versions and it's not iOS 6 yet? Or there is another way to display modal window like this from UICollectionViewController?
Thanks
If I understood you correctly what you are trying to achieve is to present one of your ViewControllers over the parent and still see the parent ViewController in the background.
First solution:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:#"SecondViewController"];
vc.view.backgroundColor = [UIColor clearColor];
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext; //self.modalPresentationStyle might do a better job here
[self presentViewController:vc animated:NO completion:nil];
Make sure your SecondViewController content is smaller than your current ``ViewController` and that you can see the background color of it in StoryBoard \ xib. The background color will be clear and will create the transparency effect.
Second Solution:
Create a Container (iOS 6 and up if you are planning to use the Storyboard IB, lower than that will let you create Containers but only progrematicly).
Set the container size 3/4 of the parent size and connect the second viewcontroller to it. Instead of segueing \ pushing to your second viewcontroller you can just
myContainer.alpha = 1;
to show it on screen.
I would take a look at the docs for UIContainerView which is used for displaying a view controller as a child of another view controller in a similar way to a non-fullscreen modal presentation.
As you are saying that presentViewController is only works with UIViewController not UICollectionViewController.
Then simply import UIViewController class in header file of CollectionViewController as displayed below:
#import <UIKit/UIKit.h>
#class UIViewController;
#interface MyCVController : UICollectionViewController
#end