Anyone knows how I can get the UISegmentedControl to overlap with the MapView and still display properly? I'm currently trying to get a UISegmentedControl to appear in from of a MKMapView for users to switch the map type. I attached screenshots below.
This is my story board. Notice that the "Map View Controller Scene" clearly shows that the segmented control is above the Map View layer.
When I run the app with this storyboard setup, the UISegmentedControl does not appear.
Now i did manage to make it appear, only if I make sure that the uisegmentedcontrol does NOT overlap with the MapView.
This is the same story board, but this time, no overlap exists between the UISegmentedControl and the MapView
The app running, clearly showing the UISegmentedControl at the bottom
thanks!
"This is my story board. Notice that the "Map View Controller Scene" clearly shows that the segmented control is above the Map View layer."
I think you really want it AFTER the Map View for the z-order to be correct.
Reverse the order of the MapView and the UISegmentedControl, i.e. drag the segmented control to below/after the Map View in your Map View Controller Scene
I had the same problem, but for me the difficulty was not the Z ordering. It was that my struts were not set properly. I had the top strut turned on, which was pushing it below the bottom of the viewable area in landscape orientation.
Related
I'm currently working on a small iOS camera app and have a storyboard-related question.
(Sorry for my bad drawing) Here is what I got on my storyboard, I have two view controllers, mainVC and cameraVC, and I added table view cells to mainVC to add a segue to cameraVC. This app is a vertical orientation app, and I want to make this app horizontally only when the user gets to the cameraVC. I'm not planning to make this app rotatable, hence this app only supports the vertical orientation if the user is in MainVC and only supports the horizontal orientation if the user is in CameraVC.
I'd add several more vertical view controllers later on, so I make the app vertical on the storyboard. However, I was not sure how should I design the camera VC on my storyboard.
While the app is running and the user gets to the camera VC, I want the app orientation horizontal (and don't rotate to vertical) and display buttons on the right side, like the image below.
So my question is while all the view controllers set to vertical, should I place buttons on the cameraVC at the bottom like the first image, or is better to place buttons on the right side with assuming the VC rotates when the user gets the camera VC, like the image below?
Sorry for the confusing question.
When designing a view controller in storyboard there is no property for orientation. There are however simulated values that are applied to whole storyboard to be either landscape or portrait.
If you want to simulate these values differently I suggest that you move your camera view controller to another storyboard. I would actually do that regardless of the issue you are facing.
If this doesn't suit you for any reason then you can still simulate your view differently. You can simply select your camera view controller in storyboard and use a Freeform simulated size like on the screenshot below.
I may have run into a bug, or perhaps I'm just trying to do things in a way that Apple doesn't want me to.
I've created a GitHub repo with a single sample project which mirrors the UI layout of my app, but with different content, that shows the issue. The app should be run in the simulator with iPad Air selected. It is strictly a landscape oriented app.
In this sample project, I haven't written a single line of code. I've replicated the issue using just storyboard. Because of this, I'm thinking the bug is in iOS or it's just not supposed to be done this way.
In the project, I have the starting UIViewController embedded in a UINavigationController. In the view controller, I have some designated space at the top, which has a simple UILabel in this sample project, and then a container view below it taking up the rest of the space.
Embedded in the container view is a UITabBarController. The tab bar controller links to 2 UITableViewControllers that have static content in them for simplicity.
The issue now is with the hit detection area of the UITabBarItems of the UITabBar of the tab bar controller. You can tap just above the actual tab bar item (below the red line, but above the tab bar section in the image below), which is not supposed to be part of the tab bar, and it will switch to the other table view controller.
In my real project this is an issue because the cells in the table are interactive, and when the user tries to tap on the bottom cell and they are clearly tapping on the cell and not the tab bar, the tab bar is "stealing" the touch and switching tabs instead.
There's about 10 points of vertical space that the tab bar is "stealing" the touch input. I've verified this in my real app by making UITapGestureRecognizers for the table and the UITabBar, with the parent view controller as the delegate and printing out the touch point y value when the delegate is informed of a tap in gestureRecognizer(:shouldReceiveTouch) and in gestureRecognizerShouldBegin().
In my particular sizing, the table receives the tap up to point 710. One point below that, which should be 711, reports as being captured by the UITabBar, but the y value isn't 711, it's 720. That continues all the way to 720, which is where the actual UITabBar area begins. At point 721, it's correctly reported by the gesture recognizer on the UITabBar as being at y value 721. So that entire space between point 711 and 720 is dead space. It's supposed to be detected by the table but it's detected by the UITabBar instead. But what really makes it "dead" space is that all the points between 711 and 720 all report as point 720, so I can't just special case the touch points between 711 and 720 to map to my table.
Is this a known thing? My theory is that it happens because the tab bar controller is embedded in a container view that isn't the full size of the screen, and I don't know if having the whole thing embedded in a navigation controller has any impact or not.
I am trying display a UITableView within a larger UIView in an iPad app, mainly because the data is pretty sparse and I'd like to have the table be a smaller area over a background image, rather than taking up the whole screen. The parent UIViewController is correctly set as the table data source and delegate, and the table looks/functions like it should. The whole view is embedded in a navigation controller; the overall UIView shows a navigation bar, as it should, that I can configure normally.
The problem is the UITableView subview also shows blank space at the top for a navigation bar--empty space above the first cell--and I can't figure out how to get rid of it. I know the space is related to the navigation controller, because when I delete the embed link in the storyboard, the space goes away. The table view doesn't present a UINavigationBar property or any other navigation-related properties that I can try to nullify.
I would post a screen shot but I don't have the rep yet.
Can anyone explain where the space is coming from and how to nix it?
I suspect the answer is related to the Top Layout Guide for the view, but I can't diagnose the specific problem.
Here's a workaround from the storyboard: Insert a UIView in the scene, then drag the UITableView into it as a subview. Check the box for the new UIView's "Clip Subviews" in the attribute window, and then use it as a mask, basically, to cover the undesired top margin of the table view. It works and doesn't require any coding, but there has to be a better way.
I'm making an app with a picker view, and when a button is pressed, the picker view pops up, and when another button is pressed, it disappears. In the storyboard, the picker view covers the bottom half of the screen, including two buttons, but when I run the simulator, the buttons and other objects that are on the screen (such as labels and text fields) get shifted to seemingly random places, including the objects that are not covered by the picker view. What exactly is the problem, and how do I fix it?
Go to the story board, select that particular view controller on which you have placed the picker view and open document outline window(which appear on the left side of story board). After that you will get the list of components present on that view. Drag the labels and the buttons to the bottom of the picker view. By doing this you will get the labels and the buttons on the top of the picker view and add the constraints to the components.
Another reason might be that you have selected other model at the bottom and ran on other model.
Just set the constraints it will solve the problems. And delete suggested constraints.
I've based my app on Apple's SplitView project type. I have a TableView as the Master, and am using different types of views as the Detail view. To select types of detail view, I'm using the fancy concept of buttons on my DetailView toolbar. When the DetailView is derived from UIViewController, everything is good. When the DetailView derives from UIViewController, but contains a UITableView then I have problems. In portrait view the toolbar is visible. In landscape mode the toolbar is hidden, even though the Tableview is moved down to allow space for it. The UIToolbar and UITableView are both defined in my NIB file which is loaded to create the detail view. Why is my toolbar invisible in landscape?
BTW, is this the best way to choose Detail view types with UISplitView? Bonus question, what if selecting a row in my DetailView tableview should bring up another View, I can't push it like I would with a NaviagtionController, so how do I go back to the detail tableview?
Thanks, Gerry
HI Gerry,
I have faced the same toolbar problem, when trying to rotate the splitView, toolbar will disappear. If you are creating the toolbar in the interface builder, try to set the toolbar properties(size), by selecting the toolbar, then --> Tools -->Size inspector, in the autosizing section, mark the left, right and upper red lines and unmark the bottom red line, then everything will works fine.
-Maria
Bonus question, I would create a UINavigationController in code, set it's rootcontroller to the DetailView tableview (self) and then push the new view on top of it.
When you react to the rotation change are you using the same view or a different one for the detail view? Seems like the new view may not contain an instance of the toolbar? Or the Tableview is covering it up because the landscape view has less vertical room than the portrait view. Are you resetting the height of the tableview to allow space for the toolbar within the 768 height when rotating to landscape?
Just a tip but whenever I run into odd things like this I remove the elements from the NIB file and create them programmatically in code and it usually solves the problem. You get a lot more control over things when you do. Overall as I've gained more experience with programming for iPhone OS I've found that I rarely put much into a NIB file any longer and do almost everything in code now.