I am not sure if the title make any sense, but I do not how else to describe it in few words.
I have a simple task I want to do. I have a UItableview in my viewcontroller. I want to create a little nice effect, so when you get to the bottom of tableview and scroll a little further down my logo / some tableviewcell will appear. When you release the finger the tableview will scroll back up to the "real" buttom.
I have searched on google and here but cannot find any solution to this.
Please ask if it is not described clearly:)
It is an effect that is seen in other apps, but I cannot remember the names unfortuantely. Will try to find example.
You can use Footer view for your logo in table view.
As Anil said I also got the idea of using the Footer view, but it doesn't provide solution for scrolling out of the box.
So I think the best thing is to set your logo as the backgroundView (but so that it is placed in the bottom of the page) and then to set backgroundColor of your cells to white (or whatever color you want to use). It should work exactly like you want.
Would UITableViewHeaderFooterView be what you're looking for?
From Apple docs:
The UITableViewHeaderFooterView class implements a reusable view that
can be placed at the top or bottom of a table section. You use headers
and footers to display additional information for that section.
Check out this blog post.
Related
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.
I'm trying to develop something like CSStickyHeaderFlowLayout but customized for my table, but I'm not sure how can I achieve this goal. The idea is
Someone can give me a hint how achieve this objective?
To add to Vollan's answer, to make the title stay still you could use a view that contains two subviews: the first is the scrollview (with the image and table as Vollan suggests) and then add another view (like a UILabel) for the title. Thus, while the image and table scroll in the scrollview, the title will stay still.
Best solution would be to wrap everything inside an UIScrollView. That will allow you to scroll to bottom of the screen and then only scroll the tableview. That way it will appear like the tableview will overlay the image.
While using a tableview within a scrollview would likely work, your tableview would have to always be it's full size (without some annoying constant re-sizing), so you'll lose the value of the enqueuing/dequeueing that makes tableViews work so well.
The CSStickyHeaderFlowLayout has example pretty similar to what you want to do, did you look at their examples? You may be able to play with it and get it to do what you want If your problem is simply having a constant title, you can just add a view above the table or use the NavBar and adjust the contentInsets
You might also consider using a collectionView instead. It's much more flexible as far as layout goes.
i have spaced out the sections accordingly but the titles i have are centered
but i would like to have it like this
its probably a real simple fix but i dont seem to be able to find it i tried playing with header footer view methods but no go, also the color of it i would like and the outline frame around the section is also what i would like thank you
You are on the right track. You need to implement tableView:viewForHeaderInSection:, not tableView:titleForHeaderInSection:. You can thus return the entire view, colored as you like, and with the label positioned inside it as you like. You must also implement tableView:heightForHeaderInSection: because otherwise the table may try to resize your view in a way you don't want.
An easy way to design the view is to make a view .xib file and design it there. You'll probably want to use a UIView subclass so you can access the label inside it later through an outlet. In tableView:viewForHeaderInSection:, load the nib, pull out the view, configure the label, and return the view.
I'm building something similar to the compose page of the native iPhone Mail app.
But, I'm putting two text fields on one row, and I want to separate them with a vertical divider (an additional view) that's the same color & weight as the horizontal cell separators.
Apple's docs say:
If you want to customize cells by simply adding additional views, you should add them to the content view so they will be positioned appropriately as the cell transitions into and out of editing mode.
But, what if I know, like in this case, that my cell will never go into editing mode?
Also, the horizontal cell separators are subviews of the cell, not the cell's content view. So, I think it'd also make sense if I added the vertical divider to the cell, not the cell's content view.
Can I just add additional views to the cell itself, instead of its content view?
You can add additional views directly to the cell, but it's best practice to add them to the cell's content view. Even if you're cells never go into editing mode, this is what Apple and other developers that may be working on your code (or you in the future) are expecting. So, this will make it easier for them to work with your app.
For example, what if Apple hypothetically decided to put gutters on the left & right side of plain style table views in a future release of iOS? Then, they would probably inset the cell's content view but not the cell itself. That way, if you position your additional views relative to the content view, your app has a better chance of looking good and the additional views have a better chance of not getting clipped by Apple's hypothetical gutters. OK, I doubt Apple would do such a thing, but the point is that if you add your additional views to the cell's content view instead of the cell itself, you're code will be more robust.
For your specific case, I still recommend adding the vertical divider to the cell's content view because you can. You might even consider setting the tableView.separatorStyle = UITableViewCellSeparatorStyleNone and redrawing custom separators by adding a separator view to the bottom of each of your cells' content views. This way, you can be sure that the style of the vertical divider you add will always match that of the separators. Again, this will make your code more robust and protect you if Apple decides to change the style of their separators. Sure, you can use cell.separatorColor. And, you can guess the separator weight with cell.frame.size.height - cell.contentView.frame.size.height. But, such cleverness might get you in trouble.
As the Buddha admonishes Siddhartha, "Beware of too much cleverness!"
I'd like to design a view like this:
Each "section", which looks like a two-cell section in the mockup, are actually or should behave as a whole, I mean, both the blank upper part and the lower part with the disclosure indicator should be an only tappable unit and navigate to another view, I drawed it like two cells because I need the disclosure indicator to be vertically aligned to the bottom.
Should I set two grouped table views with three sections each one? Is it possible to change the corner radius of a grouped table, the space between sections and the right/left margins of the table? And change the alignment of the disclosure indicator?
Or should it be better to design a view like this with buttons? Is it possible to put a custom disclosure indicator in a button, or such symbol is only intended to appear in table cells and may break the iOS Human Interface Guidelines?
Thanks!
Collection views is the best for this.
Each little box with be its on UIView, reminds me of the card app they created in iTunesU, coding together.
Hope that helps.
UICollection view is the best but if you need to support iOS5, in that case you can use plain UITableView create a custom UITableViewCell with the contentView you want with appropriate padding.
I made something like this some time ago.. There are 2 options for you to develop this..
If you are supporting iOS 5.0 and below then you can make a grid view using TableView. (The code is in this tutorial http://www.edumobile.org/iphone/iphone-programming-tutorials/images-display-in-gridview-on-iphone/). Customize it a bit for your button and ImageView size.
If you are only supporting iOS 6.0 and above then you can use CollectionView and then customize it according to your needs.