Creating a custom tab view, with each tab containing a scrollview - ios

Im trying to create an inventory page in an ios game. My design is to lock the view to landscape, then use half the screen for the "bag" or inventory (this is the tabs). The other half would be a display for details + menu controls
By selecting each tab, the corresponding view should be brought to the front of the view. Each view contains a scroll view and a static background image. The image is slightly bigger than the scroll layer since the image carries a border.
Since i only want a partial part of the view to be a tab view, i cant really take advantage of uitabbarcontroller.
Any ideas?

Related

Margin on Master View Controller on iPhone only

I have created a Master/Detail app not using the Apple Default's Template but by simply clearing the storyboard and dragging a split view controller to there.
I select the split view controller and configure it like this:
The table view controller cell inside the master has only one image view that is 240x180 points.
This image view is configured to have the Content View width and height and be centered.
When I run this project this is how I see the master view controller
On the iPad
On the iPhone
for some reason on the iPhone version the image is not filling the whole cell and is shifted to the right.
This red band is the color when the cell is selected.
I love how these APIs do not work consistently across devices.
The same Table View Controller, the same project, shows differently on iPhone and iPad.
The red rectangle is the selected background view, that I have set to red, so when the cell is selected a red rectangle shows around. The problem is that there is an old iOS bug that makes the selection background view to cover the cell content partially.
Apparently the bug happens on the iPhone, but not the iPad.
To solve the problem, turn OFF this Insets To Safe Area on the Size Inspector of the Table View. This is turned on by default when you create the table.

ios navigation bar large title issue

I'm using Swift 4. I wish to show the navigation bar large title. When I scroll I expect the navigation bar to expand/collapse.
I'm showing same content on both collection view and table view. Like showing data on tile view and list view. When the user toggles the view, either collection view or table view will show.
I have referred the link Shrink large title when scrolling (not UITableViewController) iOS 11.
As suggested in the above link, I have added the collection view next to the safe area. So the navigation bar with large title gets scrolled. No problem with the collection view.
I have added the table view next to the collection view. Here the large title doesn't scroll up. If I interchange the collection view and table view on storyboard, the large title works fine on table view.
But I have to show both the controls on my view and the large titles should work on both the controls.
Kindly help me to solve this issues. Thanks in advance.

Issue with displaying an alert like view

In Android, on the click of a button I get a screen coming up (the one on the left with just the First Name and Last Name) and on click of the more button the other fields are also displayed (the image on the right).
I tried to achieve this by loading another view on the click of the button, but this shows a view completely filling the screen and not like the one in the image with limited height and the background view being greyed out.
Also to get a screen like the one on the left I made their height constraints equal to 0, but though it showed just 2 textfields, the screen filled the whole screen and not like the one on the left.
Any idea as to how this can be achieved?
To show custom transition while presenting a controller i.e.
your first requirement - a view completely filling the screen & not like the one in the image with limited height and the background view being greyed out.
you can use UIViewControllerAnimatedTransitioning.
I have created a sample here:
https://github.com/pgpt10/Custom-Animator

Embedded TabBarController hit detection bug?

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.

Picker View displaces objects

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.

Resources