I have a piece of code pointing a UIPopoverController to a menu item in iOS 8/9, it was working in iOS7 and in fact it's in production on the App Store. For some reason, it doesn't show properly when I tried to test the code on iOS 8/9.
For some reason, the iOS framework inserts the black shadow thing about 75% of the screen. It's like it thinks the device is in portrait mode. My app is always in the landscape mode. Portrait is not considered.
When I click on the area outside the dark shadow, I get:
_UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIWindow: 0x1355065a0; frame = (0 0; 768 1024); opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x174645520>; layer = <UIWindowLayer: 0x174223920>>
I suspect something is making the framework believes the app is running portrait. The error message above is saying the area outside the dark shadow has no respondent to my clicking action. It's my suspicion, I'm not 100% sure.
and the code:
-(void) showActionControllerByPopover:(UIViewController *)actionController item:(UIBarButtonItem *)item
{
UINavigationController * const navController = [[UINavigationController alloc] initWithRootViewController:actionController];
[navController.navigationBar setBarStyle:UIBarStyleDefault];
[_popController dismissPopoverAnimated:YES];
_popController = [[UIPopoverController alloc] initWithContentViewController:navController];
[_popController setDelegate:self];
[_popController setPopoverContentSize:CGSizeMake(320, 768)];
[_popController presentPopoverFromBarButtonItem:item
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
Related
I have the following code for a UIPopoverController. It is working fine in iOS 7. However, in iOS 8, the popover becomes full-screen which I do not want. How do I keep the popover from filling the entire screen in iOS8?
CGRect buttonFrame = [[[[[self tabBarController] tabBar] subviews] objectAtIndex:index+1] frame];
popover = [[UIPopoverController alloc]initWithContentViewController:viewmapmenu] ;
popover.popoverContentSize = CGSizeMake(95, 128.0) ;
popover.delegate = self ;
[popover presentPopoverFromRect:buttonFrame inView:self.tabBarController.tabBar permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES] ;
Try to add this delegate method.
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller;{
return UIModalPresentationNone;
}
See, here is the situation. if you are presenting the popover in iPhone then it will not work in iOS 8 as Apple has completely restricted it even if it was previously working. Now you cannot present popover in iPhone as all the access to the private methods of UIPopover is blocked.
You can look into the FPopover Library in github to use popover in iPhone:-
https://github.com/50pixels/FPPopover
Here is the scenario.
Before launching my app, I make a phone call. Then I open my app, the status bar height has doubled due to call notification. and because of that, the entire UI of my app has been pushed down by additional 20pt. Switching back to phone app and end the call, when I open my app again, the UI gets stuck as just now, except that the green notification bar's gone, leaving an additional 20pt black bar on top.
This does not happen if my app is already launched before I make the call.
I've used [self.window makeKeyAndVisible];
Any idea how to adjust UI properly in this case?
Update:
Here's the code
ADTransitionController *transitionController= [[ADTransitionController alloc] initWithRootViewController:[[MainViewController alloc] init]];
transitionController.wantsFullScreenLayout = YES;
ConfigurationSetupViewController *menuController = [[ConfigurationSetupViewController alloc] init];
REFrostedViewController *frostedViewController = [[REFrostedViewController alloc] initWithContentViewController:transitionController menuViewController:menuController];
frostedViewController.direction = REFrostedViewControllerDirectionLeft;
frostedViewController.liveBlurBackgroundStyle = REFrostedViewControllerLiveBackgroundStyleLight;
if ([GBDeviceInfo deviceDetails].majoriOSVersion < 7) {
frostedViewController.blurRadius = 2;
}
self.window.rootViewController = frostedViewController;
I've drilled down the problem with REFrostedViewController. If I set rootViewController to transitionController, the layout is perfectly aligned.
Update2:
So the fact is.. when a double status bar is present, ADTransitionController will set coordY = 20 and height = 548. REFrostedViewController does the same thing.. causing I have 40 margin on top.. One thing I'm not sure is.. when is the frame of these UIViews being set?
I'm integrating a passbook system in my iOS app. I'm using the PassKit framework (Obviously ;) ). I'm using a custom tint color for all my navigation items. Is it possible to change the color of the 'Cancel' and 'Add' button? (From te PKAddPassesViewController) The blue looks horrible in my design.
thanks
In iOS 9 the button color can be changed. Subclass the PKAddPassesViewController and set the window tintcolor in viewWillAppear and make sure to set it back back in viewWillDisappear. Then use your subclass instead of PKAddPassesViewController:
MyPKAddPassesViewController.h:
#import <PassKit/PassKit.h>
#interface LHPKAddPassesViewController : PKAddPassesViewController
#end
MyPKAddPassesViewController.m:
#import "LHPKAddPassesViewController.h"
#implementation LHPKAddPassesViewController
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
((UIWindow *)[UIApplication sharedApplication].keyWindow).tintColor = [UIColor greenColor];
}
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
((UIWindow *)[UIApplication sharedApplication].keyWindow).tintColor = [UIColor whiteColor];
}
#end
There a simple way to do this in iOS 9. In the caller of PKAddPassesViewController use this:
PKAddPassesViewController *addToPassbookController = init...
[addToPassbookController.view setTintColor:[UIColor blackColor];
I don't think that you can change the tintcolor. Since iOS 6 such viewControllers are based on remote view controllers, meaning their view is completely owned by another process and inaccessible programatically.
This can be confirmed by looking at the recursive description of the controller's view:
<UIView: 0x140b0780; frame = (0 0; 320 568); layer = <CALayer: 0x140b0860>>
| | <_UISizeTrackingView: 0xe3b7300; frame = (0 20; 320 548); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0xe3b7410>>
| | | <_UIRemoteView: 0xe3b9b80; frame = (0 0; 320 568);
The _UIRemoteView indicates that the contents of the view is hosted in another process.
Edit:
Curiosly with MFMailComposeViewController it works. This viewController has an addressable navigationbarcontroller.
In Storyboard, Select navigationbar of your UINavigationController and then select the tint color
Hope this will help for you
I have a universal app that displays buttons inside an actionsheet.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:[dataObj.preferences objectForKey:#"appts_name"], #"Reserve", nil];
[actionSheet showInView:self.view];
On an iPad that automatically gets changed to a UIPopoverController. This displays and acts fine, however if I have the above popover being displayed and change orientation on the iPad then tap one of the buttons, it crashes in that buttons method where I am wanting to display another popover, saying that
-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.
If I do not rotate the iPad and just tap a button it executes the same code just fine.
UINavigationController *navBar = [[UINavigationController alloc] initWithRootViewController:addItemView];
popOver = [[UIPopoverController alloc] initWithContentViewController:navBar];
if (viewPopover) {
if (self.view.window != nil) {
CLS_LOG(#"Rect: %# - View: %#", NSStringFromCGRect(rectPopover), viewPopover);
[popOver presentPopoverFromRect:rectPopover inView:viewPopover permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
} else {
// We should NEVER get here but just incase. I don't want the app to crash.
CLS_LOG(#"No viewPopover or rectPopover - %# - %#", viewPopover, NSStringFromCGRect(rectPopover));
}
Log from the CLS_LOG
-[AppointmentViewController showAppointmentAdd] line 148 $ Rect: {{341.333, 592}, {1, 1}} - View: <UIScrollView: 0xc8c5d40; frame = (1044 0; 768 872); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0xc8c7780>; contentOffset: {-0, 188}>
rectPopover and viewPopover are legit. Why is the popOver crashing saying it isn't in a window, but only when I rotate the device?
EDIT:
I found out it is being caused because after orientation change, I am reloading the view to account for the new sizes. It seems this takes precedence in the window. It also only seems to affect the UIActionSheet.
Have you tried tried redisplaying the popover after rotation?
You know when the rotation is occurring (willRotateToInterfaceOrientation:), and then you can redisplay the popover controller according to it's new anchor point.
I'm running into a tricky glitch.
I've got a .xib, which was created by XCode when I created a new UIViewController subclass. It has quite a few elements, including some UIButtons, a bunch of UILabels, a small UIView with some other views inside it, and a UIImageView containing a mostly-transparent image.
In viewDidLoad, I set the background color of the UIImageView to a color using a pattern image.
When I display this view controller in the simulator or on my iPhone 4 (both running iOS 5.1), everything goes smoothly; the patterned background displays, all the interactions work, and so on.
When I test on iOS 4.3, however (either in the simulator or on my iPod Touch 2G), it appears that everything I'm trying to manipulate based on an outlet (e.g. [self.myBackgroundImageView setBackgroundColor...] or [self.mySegmentedControl setEnabled:NO]) just doesn't work at all.
The only even vaguely unusual thing I'm doing when the view gets presented is this, which makes it size properly in a popover:
- (void) viewWillAppear:(BOOL)animated {
CGSize size = CGSizeMake(320, 480); // size of view in popover
self.contentSizeForViewInPopover = size;
[super viewWillAppear:animated];
}
I really can't think of anything else that might be the problem. I've cleaned, rebuilt, all that stuff. Still no dice.
Has anyone else encountered this?
UPDATE per request by ott:
Added the following at the end of -viewDidLoad:
NSLog(#"self.myBackgroundImageView = %# | %#", [self.myBackgroundImageView description], [[self.myBackgroundImageView backgroundColor] description]);
...The output is:
self.myBackgroundImageView = <UIImageView: 0x6d48c80; frame = (0 0; 320 480); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x6d48b60>> | <UIImageView: 0x5f459b0; frame = (0 0; 320 480); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x5f45890>> // kCGColorSpaceModelPattern 1
So... not nil. Not sure what the story is here.
UPDATE 2:
It appears the disabling of a UISegmentedControl in iOS 4.3 doesn't dim its display, so that's what that part was about. As for the background pattern image: I can't find confirmation of this, but I'm starting to think it's a bug in iOS 4 that makes a background color using a pattern-image UIColor not display properly on a UIImageView. It works fine if I make the UIImageView have a clear background and put the pattern image UIColor as the background of the main view instead. If anyone comes up with a workaround, or confirmation that this is indeed an iOS 4 bug, it would be much appreciated.