I have three UIViewControllers being shown modally on top of each other. The third one opens a MFMailComposeViewController and send an email. However, after dismissing that view controller, various controls on other view controllers (not necessarily in the chain of view controllers) have moved in position.
For example, after dismissing the MFMailComposeViewController, one of the labels on the parent ViewController has moved down by about 20px. A scrollview on it's parent has also moved down the same amount. If I enter a separate view controller from here, an imageview is displaced. They always seem to be a control near the top of the screen, and only one per screen.
Has anyone seen this before? I've checked all the code and there nothing which could be causing it. I'm having to reset the frame on these controls every time the screen is shown to prevent them from appearing out of place. But it makes no sense to me.
Thanks.
Have you tried presenting it from the parent view controller?? I had a similar problem and it fixed the issue.
It sounds like layout randomly isn't happening, somehow. I can think of a few things to try:
Check that you're not expicitly calling -layoutIfNeeded, especially in places like -setFrame: or -sizeThatFits: — it can cause a layout of the entire view tree, which will tend to do the wrong thing if layout is already happenin (on iOS 5 it can cause inconsistent layout; on iOS 6 I've observed it getting stuck in a layout loop). You also need to be careful around some methods which perform a layout as a side-effect (UIButton.titleLabel comes to mind — the fix is to call it before adding the view to the hierarchy).
If you're using autoresizing then it should just work — except I've seen it not work if the view isn't attached to a window when its frame changes.
If you're doing layout in -layoutSubviews, override -setFrame: to call -setNeedsLayout. The usual symptom is that "switch tabs, rotate, switch back" results in an incorrect layout.
Related
I'm trying to modify the TransitionFun example that comes with ECSlidingViewController to include a RightViewController.
I've basically added another ViewController, similar to the existing MenuViewController, that appears on a swipe to the left, (or from extra navigation item on Transition View Controller).
This works fine for the Default transitions but not for the others. Fold and Dynamic transitions jump and behave erratically, while the Zoom transition locks up the app!
(just to clarify - all the transitions initially work fine if I only use the existing left menu view - they only break after transitioning at least once to my new right view).
Has anyone managed to do anything similar? Maybe someone (Mike?) could update the demo to show how its done if possible?
Thanks
I have a UIScrollView with a bunch of buttons and switches present in it. When pressing any of these items the scroll view bounces to the top of the screen. While debugging this issue I increased the content size of the scroll view to be much larger than the space that I require and the issue does not happen. I should also mention that in in the hierarchy of objects within this view controller I do not have a UIView is it possible this could be causing my problem. I have tried adding a one in but it seems to break a lot of the UIScrollView features. Does anyone have any ideas as to why this is happening or what hierarchy structure should be employed when using a UIScrollView.
Thanks.
I have a normal navigation based iOS app
I've got "loading view" which I initiate from my app delegate and use across the app, simply by showing and hiding it.
This works fine, but as soon as I hide the bottom toolbar in one of the views in the app and display it again, the toolbar seems now be shown on top of the my generic "loading view"
Any help is much appreciated
How do you add your bottomBar? Obviously not on the view itself, right? Than it would probably be beneath the overlay.
Also you should use an extra window for the loading overlay. That would solve your issues.
I basically ended up deleting the loading view and recreating it each time.
It now appears at the top of the view hierarchy each time. This fixed the problem.
In an iOS Tabbed Application I'm making, I've got tabs to load different viewControllers, which is pretty standard. What I'd like to do is make a few buttons (with images on them) load up another view with the button image maximized to the screen. However, I'm not really sure how to go about doing this. I don't want a new tab for this, I just want another view to show the full image, and then a button to return to the tabbed view. I've experimented a bit with making a subview to do this, and I've attempted to change the main viewport to the new view, with no success. If someone could point me in the right direction, and maybe give me a solid concept as a jumping-off point, I would really appreciate it.
And to clarify, I'm not looking for "the best way", per se. I'd be willing to accept a quick and dirty fix. But if you know of more than one way to handle this situation, I would appreciate whichever one you personally think is better.
I would do it by creating a UINavigationController to use as the primary tab view. When you want to show the full screen button, you create a new UIViewController subclass (below) and push it. That class will return YES for the method "hidesBottomBar" (its something like that).
This new view controller will be a traditional controller. You can create a UIImageView to fill the view (or you can probably replace the view with the imageView). In the viewDidLoad you'll set the UIImage of the view (or you can enter its name in the nib).
When someone clicks on the button, then you'll pop that view and return to your tabbed view (where the tab bar is showing).
I did something like this (not a big button), so I know the tab bar can be made to hide on the push. You can also hide the navigation bar so it never is even show (again, not 100% sure at the moment how to do it but its possible).
I have a UITabBarController displaying a number of settings-screens in my app. I want them to be shown on just a part of the screen for layout reasons. In fullscreen, the lists become unreadable (too wide), there are just a few controls per page making the page feel very empty, and the tabbar buttons are far away from the content (Fitts law).
Using presentModalViewController with the UIModalPresentationFormSheet style gives me the size I want. I do this on top of an empty background, since in my case it doesn't make sense to display anything behind it. The "real" working area is displayed with another presentModalViewController in fullscreen mode on top of it all.
This works but feels like a hack. One problem is, I can't make the background behind the settings dialog move in the transition to fullscreen with the UIModalTransitionStyleFlipHorizontal style.
TL;DR
Can I embed a UITabBarController non-fullscreen in another "background"-view? I can't find any information of how I would do this.
Can I embed a UITabBarController non-fullscreen in another "background"-view? I can't find any information of how I would do this.
Why don't you try it out?
Create a container view of the size you want the tab bar controller to have.
Create the tab bar controller.
[containerView addSubview:tabBarController.view];