Showing Keyboard causes the cell row containing active text field hides under its section footer - ios

I just successfully set up content inset adjustment to make visible, dealing with the keyboard of iPhone, of the active text field on a cell row managed by a tableViewController (dynamic table view and different custom cell types - some from XIB and others from code). Well... almost success; except for the below issue:
a section footer doesn't move up the same extent of the rows of the section so that often the footer makes the active text field invisible. A user has to scroll the table view a bit to show the row with the active text field (strangely the footer stays floating above the rows in scrolling).
Anyone has seen such weird thing before? Is it the section footer moving with the section rows together as an integral unit? How can the footer stay floating above the scrolling rows of the section? Please shed me some light and I even don't know where/how to start debugging such issue.

Thanks folks for editing my post. After many hours of struggling, I finally find the reason from reading pages of Apple document, which is of enum UITableView.Style having two cases:
.plain : Section headers and footers are displayed as inline separators and float when the table view is scrolled.
https://developer.apple.com/documentation/uikit/uitableview/style/plain
.grouped: Section headers and footers do not float when the table view scrolls.
https://developer.apple.com/documentation/uikit/uitableview/style/grouped
Apple should rename the enum to HeaderFooterStyle instead to make our finding easier (another example of clarity over brevity)
I hope someone else bumping into the headache might find the post useful.

Related

How to create table view with rounded corners around the list items

I am trying to recreate a menu similar to the ones in the detail view of the iOS 13 Health app. Please refer to the marked up screenshot.
I know that this can be done with a table view. There's a section title and list items. But what I want to achieve is similar to the look shown in the screenshot whereby there's a background colour on the list items (not including the section title) and rounded corners at the top and bottom of the list.
Can anybody tell me how I can achieve this with the table view? Or point me towards the right direction? I already know how to setup table views and programmatically add the details. I just need help on how to achieve the styling as shown below.
Thanks!
So, I was able to figure it out. For the benefit of the devs who stumble in the same dilemma, I'm posting my solution here. But I will be tagging Glenn's answer above as the correct answer as it lead me to find the solution. Thanks again Glenn!
It appears that I didn't have to do anything special with my code. I just discovered that on XCode 11 and iOS 13, there's a new table view style called "Inset Grouped". You may set this property from IB or via code.
With a quick experimentation I was able to come up with the result as shown on the screenshot below.
It's not that complex to do. This one of the multiple ways that that style can be done.
a. You can use grouped tableView, as what you've indicated in the screenshot.
b. Provide section title, or better yet, a section view (for more customization!).
c. For each section, you have ONE tableViewCell.
d. For each cell of that c., you will have a tableView.
e. For each tableView of that d., you will have your a new cell of course (item cell).
f. How to compute for the height of the tableView of e.? There are multiple ways.
Provide static height (if your number of items are static).
If dynamic count, but you have constant height of each cell, then you can just compute it like so: itemsCount * heightConstantOfCell
If again you have dynamic count of rows/items, and you have iether constant height of each cell or dynamic height of each cell, then you can observe the frame key of the whole tableView.
g. Finally, just add some corner radius to each container view of your tableView in d..
Note, this screenshot ONLY shows the item g.. It's merely a corner radius of each container view of your tableView in a tableViewCell that is a cell of your main tableView.
Another way is to use UICollectionView, but kinda more complex than what I've discussed - at least for me.

How to implement the following table?

I'd like to implement the following view (circled blue):
However, I'm not sure what view to use.
On the one hand, when using a UITableView, the cells' width cannot be changed.
On the other hand, when using a UICollectionView, I need to have sections (exactly three sections; each section represents a game state, either 'running', 'waiting' or 'ended').
Cells shall be added dynamically (the data for the cells is retrieved through an API).
What is the preferred basic structure (basically the view) to use?
I'm not looking for a fully coded solution! I'd just like to know what view I should be using.
Given that you have a simple one-column set of cells, it looks like a table view would be a good fit. A collection view can do everything a table view can, but it's more work.
I'd suggest using a sectioned table view with section headers, and a custom header view that's mostly transparent and shows the background behind it. (The section header's view would still be the same width as all the other cells, but it would be transparent, have a fill color of clear, and have a subview that draws the boxes with your section headers in it.
I don't know enough about the content (can't understand that language) but looks like a quiz app?
The basic outline for displaying the majority of the dataset looks to be a UITableView in grouped mode (where "Warten Auf" and "Beendete Spiele" are groups).
If the first row (under the green button) is part of the data set you can either leave that without a section/group header, use the green button as a header view for that group or use the green button as a header view for the UITableView itself.

Blank Page Footer leaves space in Crystal Report

Problem:
I have a multiple page footers which are suppressed conditionally, but even after hiding the page footer, it leaves space and whole formatting is vague now in my Crystal Report.
Is there any way to remove extra blank space from Report when Page Footer is hidden?
I have tried using "Suppress Blank Section" option, but then also no help.
Crystal Report version - 2008
To give a better answer. I'd need more details of the footer contents & conditions for suppression. That said, I would try the following:
Set the footer contents to also be conditionally hidden/suppressed with the same logic used in the footer section itself.
If that doesn't solve your problem, try debugging by removing all footer contents. If "suppress if blank" functions correctly after this, then your problem is that one of the items in the footer is not actually blank.
If the footer still isn't suppressed, try going into design mode, zoom wayyyy out, and see if there might be something outside of the visible page template in the footer section that is causing the section to not be blank... if page dimensions or settings were changed at some point, or you placed a lot of items in the report at the same time, CR will sometimes cause items to be outside of the dimensions of the page template, but still within the section.
Those steps aside, there's not much we do without specific details. Try giving an example of the desired behavior, and desired conditions to trigger that behavior, and we can advise further.
If your objective is to have varying footers and display only a single one based on the conditional suppressions, then what you want is the "Reserve Minimum Page Footer".
To find this option, open the Section Expert and select "Page Footer" (the parent to Page Footer a,b,c etc.) Under the 'Common' tab you should find the "Reserve Minimum Page Footer" option.
What this does, is instead of reserving space equal to the sum height of all your footers, it reserves space equal to the height of your biggest footer. Which isn't perfect, but it is better. (And if all your footers are about the same height, it is perfect. If you had varying sizes, you will still have some blank space when displaying a short footer, and that blank space will be BELOW the footer, so I would adjust all footer sections to be the same size, and shift the content to the bottom of the section.)
The problem with this though, and this is the problem I am having and am yet to solve, is when you want to display multiple footers, it will still only use the space that is reserved, which is the height of the single largest footer, anything else that is displayed overflows below the page.
I am yet to find a solution that will dynamically adjust the height of the footer based on what is displayed in the footer.

UITableView or Collection View?

I have an iPad app which always stays in landscape mode. It is more of a data centered app with 5 columns and couple of hundreds of rows.
In current implementation, I have used UITableView. The rows' height could be anything depending on the data that comes in from server and all the columns can have different size.
The question is, can I use UICollectionView instead of UITableView? Will there be any performance issues? If yes, which is better in grid like layout? I understand UICollectionView is to be used in iOS pictures app like layout but how it behaves for grid like layout?
Thanks,
Pruthvid
What you describe is exactly what UICollectionView is designed for, it's the perfect solution. The limitation is only to the version of iOS you will be able to support (if you need to go back that far).
The choice really comes down to the visuals you want. Of you want each row to have a height defined by the maximum height of any column value in that row and the row appears as a single row item and the last row of the table should be full width then you may prefer to use a table view.
The collection view gives you more options for accessory views (as opposed to just the headers and footers of the table view).

uitableview custom transparent header

I am using section headers to show a small image 'floating' next to cells from appropriate sections. The section header is transparent and contains only a imageview.
The initial problem with this solution was that the section header takes up height, which looked strange (there was unnecessary empty space in the beginning of each section + the image should be aligned with the top of the first cell when tableview is scrolled to the beginning of the section). The fix for this was to set section header height to 1px. The image was still in place, but the header didn't use any height and everything looked great.
However now I need to add a UIButton on top of that image, and unfortunately it doesn't work when the header has 1px of height. It is not hidden or covered by anything and it is drawn correctly, but the set selector doesn't get called. If I set some height, the button works.
In short - how to achieve either a working button in a section header that has virtually no height, or how to achieve a section header that has normal height but always overlaps cells (doesn't use any space when the tableview is scrolled to the top of the section)?
Any help will be greatly appreciated.
One way you may be able to get this to work is to add a transparent view over the table. You would intercept touchDown and touchUp. You could calculate whether they were over one of your buttons, and if so send them directly to the button, otherwise just forward them. the reason you don't get the touch events is probably since the touch does not fall into the header frame.
David H suggestion was my initial idea as well but I was hoping to find a more elegant solution. Anyway, that's how I ended up implementing this feature.
I kept the code as simple as possible (I'm sure it can be done in a more optimized fashion, works fast enough for my needs) - each image added to a section (no need for overlaying buttons anymore) was also added to a dictionary with section numbers as keys.
When my mask layer view (the transparent one added over my tableview) is being touched I simply check with CGRectContainsPoint if the touch corresponds to any of the views in my dictionary.

Resources