Can somebody help me to do the following in Swift:
I have two elements called Topic 1 and Topic 2.
I need to click on the Topic 1 (in the down arrow image), then deploy some content just under my Topic 1 section.
I use a UITableView to display the data (topic 1 & topic 2 rows), but I don't know if displaying content below each row like the following image is possible with an UITableView.
Anyone know a way to resolve this?
Thanks!
Two high level options:
Display topics as section headers instead of rows. Detect tap of
section header and track the "active" section in your table view
data source. Only return a row count greater than 0 for the "active"
section. When the "active" section changes, reload the old section
and the new section.
Create a cell that displays both the "Topic" and any details. Implement the table view's delegate and return a height that shows the details only for the "active" topic. For all other rows, return a height that will only show the header. When the selection changes, reload the old and new rows to animate the height changes.
Don't try to "deploy the content" below the cell. Add it to the cell. In other words, you modify the cell or replace it with another cell built exactly to accommodate this extra material.
Related
How to design and code this in swift(IOS) AND Xcode.If we tap on down button it should display items and vice-versa like this:
You need a Collapsable TableView. In order to achieve that, in your TableView you must keep track of which sections are collapsed (contracted) and which of them are expanded. For this you need to maintain a set of indices of sections that are expanded, or a boolean array where the value of each index indicates if the corresponding section is expanded or not. Check for the values at the specific index while assigning height to a certain row. Check this link for more help.
Refer ans by #Cristik.Refer my previous ans for more info.
You need expandable table view. Basically, you need to control the open and close of sections of your table view.
Here is an good example with working code & animation written in swift 3.0
I'm trying to build an accordion style ( expand/collapse ) list in IOS/Swift 3. Was confused on which approach to follow like a static UITableView ( since my sub divisions have different types of Ui Controls in the cells ie some have checkbox ,spinner, textview etc. with labels to show configure a list of different Valves) , UIView with nested UIViews sections with an option to clip views . But both have been messed up with without any success.
Illustration
http://imgur.com/a/Bs9SF
Below are the links I followed
https://github.com/justinmfischer/SwiftyAccordionCells
http://www.appcoda.com/ios-static-table-view-storyboard/
https://github.com/Weebly/TableSchemer
https://github.com/Alliants/ALAccordion
Any other approach without UITableView?
Please help . Thanks in advance .
Static vs dynamic table will depend on your data source. Does your data source for your table change? If so you'll want a dynamic table, if not then you can design it out in a static one.
As for the accordion feature, what I've done in the past is to add a tap gesture recognizer to the header view of each section. When the tap is detected I change my datasource and reload the table view. What happens is that number of rows for section is called on reload, and I return 0 so that none of the rows show. When tapped again you can go back to showing the normal number of rows.
To get the animation you need to use delete rows with index paths and animate it.
I am working with Custom cell merge functionality in my UITableView.
I have Table view with 3 different column. First column is for username, second is for Facility that is provided to user and last is for the permission that is given to user for the particular facility. And currently my Table view shows as follows:
As you can see in the above image the Username cell is repeating, if username is same for different facility. So it's not looking what I want.
I want to merge Username cell column to stop repetition. And want to merge cell as below given image.
I got count of Different Username which is repeat in database table with NSSet but i did not get clue how to merge this cell.
Please help me for this and provide some sample code for the same if possible.
Thanks in advance.
TableViews are single column. You may have to use 3 TableViews to achieve your UI.
If you use 3 TableViews - all you need to do is set the height of the cells in the first tableview (User) as multiplers of number of respective rows in the second tableview (access).
For example, the height of 'User 1' cell would be 5 times the height of a cell in the second table (access). The height of 'User-2' would be 2 times the height of a cell in the second table (access).
The best way is to use a section.
But still if you want to make UI like that, then the process is as below.
If you have data like in 2nd image then you need to create 1 row for 1 user.
Then you need to create 2nd and 3rd column, by dynamically.
i.e. if User 1 has 5 row, then you need to create 5 Custom view in User 1's Cell programatically.
Then you need to manage height of cell also programatically.
i.e. if User 1 has 5 row, and you take height of 1 row is 50 then you need to make cell of (5 * 50) = 250.
You can achieve this output by taking only single UITableView.
Create your UITableView as shown in image.
Follow below steps to get the desired result.
================================================
Create a UITableView with dynamic row height. (using
UITableViewAutomaticDimension)
Create a UITableViewCell as shown in image like Left side is UIView containing UILabel as User.
Create UICollectionView for right part of your TableViewCell containing two 2 columns for facility and permissions.
Disable scrolling for the CollectionView.
Give Height Constraint to the UIView (UserView) created above.
Now to populate your tableview:
Get the number of count Facility for every user and set Height of the UserView as:
facilityCount * CollectionViewCell item height
By this way you can achieve your output in very efficient way without any multiple scrolling issue.
In table view with many rows, is it possible to have the top row (row[0]) "frozen",
while the rest of the rows 'scroll' up an down.. If you have any hints about this, it would be appreciated..
The only way to do this would be to use a section header as the top row. Otherwise, do the top row as a separate UI element.
I have table view which contain 7 sections and each section has different number of rows. The problem is when I select a row in section and check mark. Others sections rows are also checked mark and when I scroll the table. then unwanted check marks are appeared. It show very goofy behavior.
If you have any tutorial or sample code, please share it with me.