This is quite a strange behaviour and I couldn't figure what was wrong out. In iOS7, this code below works as expected but in iOS 8, it has a strange behaviour.
UIView *mainPopupView = [[UIView alloc] initWithFrame:CGRectMake(10, ([UIScreen mainScreen].bounds.size.height-300)/2-50+20, 300, 380)];
mainPopupView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:mainPopupView];
In iOS7, these codes add a white mainPopupView to the present view controller, everything is working properly. But in iOS8, after mainPopupView is presented, a black screen (like an UIView with Black blackgroundColor) appears behind mainPopupView. IMO there has some change about the addSubview: method, I tried various searching on Google but no result. Anyone please explains to me why this happens and how to resolve it?
Thanks in advance.
Try setting the modalPresentationStyle of your PopupViewController instance to UIModalPresentationCustom before presenting it modally.
In case you want to know why this happens, when you present a UIViewController, after the transition animation finishes, the previous view controller is removed from the window hierarchy, since it is not being displayed. When you set the modal presentation style to custom, you are telling the system not to remove the view controller that is presenting. I don't know why it was working pre iOS8.
Related
I'm not for sure if my title responds what I want to ask but let me explain;
I'm using storyboard, I have created "HomeViewController" and set it as custom class.
Also, I want to create a view with programmatically and add this view to "HomeViewController" 's view.
These TabBar, GreenView and Logout Button are necessary. Because I added them via interface builder to see how quickly they appear on the screen and whenever I build and run my app, these components are load very quickly. They are not blinking or appear after a sec. They are stable!
Here is a simple code;
- (void)viewDidLoad {
[super viewDidLoad];
UIView *dummyView = [UIView new];
[dummyView setFrame:CGRectMake(0, 0, 200, 200)];
[dummyView setBackgroundColor:[UIColor yellowColor]];
[self.view addSubview:dummyView];}
When I run my code, the dummyView with yellow color appears on my view, yes, but with a delay of few seconds. It is really annoying!
Could you give me any idea please? When I use .xib I don't have any issues like this.
What should I do to show my view while my application starts without
any delay?
Is viewDidLoad method good enough for this? How about loadView method?
What is the reason I had this issue on storyboard?
Updated
I'm going to upload a .gif:
Thank you!
I found the solution, its really silly thing.
On my project there wasn't any SplashScreen. So it was immediately launch my main and it looks like views appears after some delay.
I have added SplashScreen and everything is as it should be!
I'm having a little problem when trying to go to the next UIViewController from a UICollectionViewController. The problem is: While the next view is pushed, a black background seems to be added behind the right side of the navigation bar. I tried to replace the next view controller but the problem is still there. But when replacing the UICollectionViewController with another one, the problem vanishes.
Note: this problem seems to be an iOS 7.1 bug. Because i don't remember that it happened before I updated my devices.
Here is a Video of my problem if you didn't understand me
Anyone can help ?
Thank you all in advance and sorry for my english,
Bader
Setting self.navigationController.view.backgroundColor to the color you want will solve this problem.
I had exactly the same problem.
It's a bug.
UINavigationController view has a black background, and it spoils translucent Navigation Bar at transition time.
To resolve this issue, you should change background of UINavigationController in code by this way:
self.navigationController.view.backgroundColor = [UIColor whiteColor];
Or set view color of UINavigationController in Interface Builder:
Ok, i finally knew what caused this problem. That was because i added an ILTranslucentView as a subview of a UICollectionView cell. Also, using a UIToolbar instead causes the same issue ( i still believe this is an iOS 7.1 bug because this wasn't happening before ).
Solution: remove any UIToolbar from your view controller.
While the next view is pushed, in that view controller’s .m file remove self.edgesForExtendedLayout = UIRectEdgeNone; if you wrote in your code.
self.navigationController.navigationBar.translucent = NO
(iOS 7.0.3, Xcode 5.0.1)
I have a second UIWindow in my app used to display a custom magnifier above the status bar. However, once I set the rootViewController of this window (for interface rotation & some other stuff), the main window goes black during the interface rotation animation.
To reproduce: create single view iOS application and add the following to the main UIViewController.
// To #interface:
#property (nonatomic, strong) UIWindow *secondWindow;
// In viewDidLoad:
self.secondWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.secondWindow.rootViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
self.secondWindow.hidden = NO;
Any help appreciated.
I will add another answer, because I have found a workaround that actually works. Set the window's background color, as well as the view controller's view's background color to a color with an alpha of 0. Do not use clearColor, but rather use something like greenColor] colorWithAlphaComponent:0.0]; It works.
According to an Apple engineer on the dev forums, this is expected due to the window adding a black background to avoid things behind it to be seen (i.e. behind the main window normally). I opened and issue with the Apple bug tracker, #15398141.
Nevertheless, I worked around the issue by hiding the window in willRotateToInterfaceOrientation:duration: and unhiding it in didRotateFromInterfaceOrientation:, which luckily is not a big deal in this case.
This is a known issue, and there are many radars open for it. Best solution so far for me is to add a view as a subview to the window, and manage rotation yourself. This works well.
Make window.opaque = No whose default value is YES. In my case it solved the problem.
I know there are other posts about this issue, but they don't seem to work for me. When a particular view is pushed by my uinavigationcontroller in my app, I rotate the view to landscape mode and hide the tabbar. however, when the tabbar hides instead of displaying the view behind it displays a blank white space.
To solve this I used the following line of code in my viewDidLoad method as suggested by other posts about this issue, but it didn't solve it.
[self.view setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
If anyone knows what's going on, please help.
Thanks,
You should set setAutoresizingMask: in your view (whether in nib or code) to UIViewAutoresizingFlexibleHeight or UIViewAutoresizingFlexibleBottomMargin (don't sure which one) that should do the trick. In case this donesn't solved your problem I guess that you hide the tabbar by using setHidden:. Try calling this instead.
VIEW_CONTROLLER_THAT_ABOUT_TO_SHOW.hidesBottomBarWhenPushed = YES
[navigationController pushViewController: VIEW_CONTROLLER_THAT_ABOUT_TO_SHOW animated: YES];
If your view is the right size then try calling [self.view setNeedsDisplay]. It should do something similar when you change the size though so I'm not sure.
I have an iPad app that has an MKMapView embedded in a UINavigationController which is displayed in a UITabBar. I am displaying a popover controller over the map with
UIPopoverController *myPopoverController =
[[[UIPopoverController alloc] initWithContentViewController:myContentView]
autorelease];
[myPopoverController presentPopoverFromRect:myRect
inView:mapView
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
The popover displays fine. However, it does not have the nice animated effect: it just immediately appears onscreen. Similarly, when I dismiss it it just disappears without any animation.
Anybody have any idea how I can get the animation to work? Should I try displaying it from another view? Is there some property on something that I might have neglected to set?
Despite the animated:(BOOL) parameter, it appears popovers never animate when presented. I've tried a dozen first and third party apps.
The dismissal should animate however, provided you pass YES to dismissPopoverAnimated:(BOOL)
Assuming your popover animates outside the map view, I would try placing the map view into a container view whose frame is the same size as the map view's. From there, it's trivial to present the popover in the container view.
According to Apple's documentation, MKMapView isn't supposed to be subclassed, so like UIWebView, it strikes me as one of those views whose guts are better left untouched.