if horizontal, it makes two side-by-side copies - ios

In vertical orientation, this basic layout is fine. But in horizontal orientation, two copies of the layout are generated. Any hints about what might cause this?
Thanks in advance... puzzled, I'm still getting oriented to the Xcode interface.
No custom code yet, this is all done via the Xcode GUI.
I've added a screenshot showing the constraints.

Because there were no duplicate elements and zero logic in place yet, the issue was likely more fundamental. So we started with RootViewController.swift and found that some action or setting had inserted a custom pageViewController. Sure enough, it was creating two view controllers when in landscape orientation, as the following code comment describes:
// In landscape orientation: Set the spine location to "mid" and the page view controller's view controllers array to contain two view controllers. If the current page is even, set it to contain the current and next view controllers; if it is odd, set the array to contain the previous and current view controllers.
We commented out the code that had been inserted and the issue is resolved.

Related

Create view for iPad out of existing views suitable for iPhone

To put it simply, my app has two main views: the first serves to choose some values, the second displays a report. Both are TableView based.
The app looks well on iPhone with any screen size and for any orientation, but since the app’s thought to be universal, I want to get rid of those gaps between elements when the app runs on iPad.
I decided to have the app displaying both views on iPad screen simultaneously as official YouTube app does:
(1) and (2) are the first and the second View controller.
I see it this way:
1) Some initial view controller (additional navigation view controller?) checks idiom (iPhone / iPad) and chooses the next viewController. If idiom is iPhone, the first view controller is pushed.
2) If idiom is iPad, the «new» view controller is pushed. It has two view containers containing the fist view and the second view. Containers have autolayout constraints etc.
Questions:
1) Is it a right idea in context of Apple app design philosophy? What’s the better way to create iPad view combining existing ‘iPhone’ views?
2) Where to check for device type? Shall I use the second storyboard or something? Maybe there’s a good tutorial for this case, I didn’t find one.
Thanks in advance!
For the 2nd part of your question I think you want to look into
I think you want to look into Size Classes and Auto Layout
You can make a single view but depending on the size / orientation of the device - you can enable/disable certain components of the view.
You can pin views so that in portrait you have your 1st layout and in a landscape you have your 2nd layout.
With regards to your 1st question - you do have the ability to embed a view inside of another view
I'm not sure if this is what you are looking for - but as far as what apple is pushing I believe size classes is what they "suggest". You can do a lot. The only thing is make sure you turn on the assistant editor into storyboard preview mode it will help a lot.

Table View with extra View. View keep resizing to maximum

I have a tableview, that is working fine. I have added a view to the top, so I can add some extra fields. I can't post images yet, so going to try and describe.
Navigation Bar
View
TableView
When I build it, it looks good.. However when I run or close the project and reopen I get this:
Navigation Bar
View
TableView
With the view taking up the complete page, pushing the TableView to the very bottom.
Any thoughts on why this is happening and how to fix it?? I can resize it back to the size I want using the size inspector, but it doesn't keep the value.
I have built a test project with the same screen layout and it works perfectly. I can't see what is different between the two projects is. Thanks
Yes, this was an auto layout problem.. After looking around the web, and trying various solutions I decided to use a view controller, and add my own tableview and tablefviewcell to that, along with my other labels and buttons. Once I built the methods the first time, I found this to be much cleaner solution, than attempting to mess around with the tableviewcontroller.

UIScrollView's Frame getting changed randomly

In my view I am using a UITableView that is controlled by a UITableViewController on the top half of the screen. The remaining screen is used for a UIScrollView that contains a view that is controlled by the main UIViewController.
When I perform a pull down to refresh in the UITableViewController, (for some reason if the number of table entries is less than or greater than the initial load value, the UIScrollView in the main UIViewController's frame gets changed to the screensize...
Essentially it breaks my paging unless I reset the scrollview back to the intialized size...
I have no idea why this happens as the UIScrollView is not used in the UITableViewController. The only scrollview that is used in the UITableViewController is the UITableView's to handle pull down to refresh...
Does anyone know why the main UIScrollView's contentSize gets changed randomly when it shouldn't even been accessible from the UITableViewController class?
Thanks
Just tried it here, and I can't duplicate your experience. I'm guessing you have an unexpected or inconsistent view/controller hierarchy? Look at the controller of the table and scroll views' common superview. Anything fishy there? Remember: view controllers manage sets of views. Container view controllers manage other view controllers and have special rules (see: The View Controller Programming Guide, esp. -addChildViewController:, etc.).
I'd suggest opening a blank project and trying to recreate the problem in its simplest possible form. If it's magically fixed, what's different? If it's still giving you trouble, send us a link so we can see the details of how you have things wired.

iPad UISplitViewController view frame

I wonder how I can change a splitView.view.frame ?
In my app I'm using a tabBarController to display differents splitViews by tab.
But I need to leave an empty space between my tabBar and my splitView to put another view.
I tried to change the splitView.view.frame but It doesn't work... any idea ?
This is from the Split View Controller section of the View Controller Programming Guide for iOS,
"The UISplitViewController class is a container view controller that
manages two panes of information. The first pane has a fixed width of
320 points and a height that matches the visible window height.
The second pane fills the remaining space."
So, I'd say you can't do it. But maybe someone else has a solution for this.
Word of advice, though: don't complicate your interface. Try and think of a better way to achieve what you are thinking of showing in that intermediate view. Maybe place it somewhere else or present it in some other way.

How to properly switch UIViews

I want to have multiple views in my application that I switch between.
What is the proper way to switch between UIViews that also supports UISplitViewController?
Is there a support way to switch or are Apple's controller classes designed to be root and root only?
I've tried having one root view and root controller and swap subviews in and out. One of the subviews is a UISplitViewController. It did not like the arrangement and does not display correctly. The detail view was not displayed, the master view displayed wrong orientation and wrong size.
I've then tried managing adding and removing one subview from the UIWindow in the app delegate. This works most of the time. However, the views added after the applicationDidFinishLaunching method do not appear setup correctly. They mostly look correct, however sometimes the orientation thinks its portrait when in reality its landscape. Also, when I try to display a popover, it shows up in an incorrect location. If I change the orientation, it redraws correctly. I've also have some random instances where the UISplitViewController view does not fully display, as if its frame is incorrectly sized.
Any suggestions heartily appreciated.
In applicationDidFinishLaunching, your objects haven't completed loaded from NIBs yet. Try using a viewDidLoad method instead.
What is the user-interface for switching between views? If one of these views represents a transient mode that the user enters and then exits, consider using a modal view. (See presentModalViewController:animated:.)
I would need more details about what you're doing to answer more particularly.

Resources