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.
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 have a NavigationController and I want to make a View that animates itself from the top of the screen and sits above navigationBar. I'm initialising viewcontroller from a xib and it works perfectly when I add it as [self.view addSubview:myView]; , but it sits below navigation bar. When I try to add it as [self.navigationController.view addSubview:myView]; it places it on top of navigationBar as intended but view doesn't display any of it's subviews placed in xib. I can't see why this is happening, have been trying to solve this for hours.
UPDATE
My custom view from a xib is paired with custom ViewController class and I added this code in it :
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(#"!!! %i", [self.view.subviews count]);
}
if I add myView to self.view it prints 1 (there's actually 1 subview), but when I add it as self.navigationController.view -viewDidAppear is not even called. But it does appear on the screen with no subviews. Now I'm even more confused.
I think you need use this:
[self.navigationController.navigationBar addSubview:myView];
Why don't you just remove the navigation controller if you don't need it? Another way is to hide the navigation bar so that view occupies complete space and then show the navigation bar again when needed.
I could help more if you provide some code with the views.
Turns out I'm an idiot. It's a really simple scope problem. I was instantiating a local variable of my VC inside the method, and of course it was released at the end. As soon as I assigned my VC to a global variable all started to work like a charm. Easy as that.
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.
I have a UINavigationController with a left and a right button on an app being used as a remote control for a piece of hardware. I would like to show that the hardware is connected to the app by displaying an icon in the navigation bar to the left of the right button. From the documentation it looks as though I can only add UIBarButtonItems which make me suspect there is another, more conventional place for my 'connected LED' indicator.
So my question is can I display an icon in a UINavigationController navigation bar and if not where should I display it?
UINavigationBar is a subclass of UIView, so you can add items to it like this:
[navBar addSubview:whatever];
The navigation bar is a property of the navigation controller (i.e. you can reference it like this self.navigationController.navigationBar).
There isn't really a "conventional place" for something like this. :)
I suspect this 'connected LED' should be displayed on all views, regardless of the current view (and its UINavigationItem). If that is correct, the easiest way would probably be to NOT put that icon in the actual UINavigationBar, but place it as a separate UIView in the UINavigationBar's superview.
you should be able to just create a uiview programatically and add it as a subview of the navbar
UIImageView *connectedView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"connected-icon.png"]];
[self.navigationController.navigationBar insertSubview:connectedView atIndex:0];
[connectedView release];
if insertSubview doesn't work as you expect try addSubview:
[self.navigationController.navigationBar addSubview:connectedView];
You probably want to create the connectedView as a property though so you can (more) easily remove it when you are no longer "connected".
see this other examples of the approach
try this code
[[[yourViewController viewControllers] lastObject] navigationItem].titleView = yourImageView;
worke for me in customising navigation bar in mail controller. Hope you get some idea from here.
I'm using UIModalTransitionStylePartialCurl to show a modal view in iPad.
modalViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[[self parentViewController] presentModalViewController:modalViewController animated:YES];
self is the right side view controller of my SplitViewController.
When I do this, the page is curled all the way to the top even though the size of the view of modalViewController is small. I only need it to curl a little so it would reveal ONLY the area taken by modalViewController. What I'm trying to do is something exactly like the iPad maps application settings.
I tried using all the modalPresentationStyle options for the modal view and I also tried setting the modalPresentationStyle.view.frame to a small CGRect but still couldn't get it to work.
Can anybody help on this...thanks in advance..
Just leave a clean space (No Controls or Images) in the top of your PresentedViewController, the Framework make the rest.
I have yet to find a more optimal solution, but I've been able to get good results by making the modal (revealed) view the same size as the parent (curling) view. iOS looks at the subviews to determine where to stop the curling and shows "just enough" of the subview to keep the subview pieces on-screen.