Horizontal paging in iOS with UITableView like memory design? - ios

White boxes represent items in an NSArray.
Swiping from a directing changes the indexes and update the items accordingly. (not scrolling 1 by 1 but like changing pages. So, changing all 4 items at every swipe)
In this example, there are approximately 20 items in this array and we are in the second page. It currently shows item at index 4,5,6,7.
There can be more items.
I don't want to create at least 20 items and keep them at a far frame (CGRect).
I want to have a scheme like UITableView, where it creates approximately 6 items for infinite number of items if the tableview can show only 4 items at a time.
So, I plan to have 5 or 6 items for 6+ items and just update the item's contents (item = white boxes) according to real data at that index of NSArray
Is there a quick and ready way to do this easily or may there be a better way to do something like this?

instead of using tableview you can use scrollview with page control.
try using this link :https://github.com/cwalcott/UIScrollView-Paging/tree/buttons

Related

List items are not refreshing when room data change

I have a lazy-column with a pager to show items using paging-compose 1 alpha 16 (latest).
I have some issues around.
1-> Every time an item is off the screen and back again it comes with a leak on the view like it was loading the entire data.
2-> When an item is updated on DB it changes its position on the list (as expected) but it is not show in the new data.
3-> The new data is only displaying correctly when the item goes out and get back to the screen.
I follow this tutorial to achieve the actual behavior https://medium.com/simform-engineering/list-view-with-pagination-using-jetpack-compose-e131174eac8e
My paging Size is of 50 items and i have leaks even with only 15. The views are simple. They have an image and 2 texts. And i tested without the image as well and still remains the problems.
The problem with the second point was that my text where custom AndroidViews and i was missing the update state parameter. For the other problems i still waiting for help

Quickreports with multiple pages

Assuming that I have a Title, sub detail and footer. Both footer and title are static (won't change) while the sub detail is dynamic, basically drawing a table from a database.
How is it possible to make it load a specific amount of lines in the Sub-detail and creating as much pages as needed? Let's say I have 30 lines in my database table. and I want to limit 10 lines per page. that will make it 3 pages
you could have a local variable keeping track of the number of time the detail before print event has been called. Once it hits 10 call NewPage()
You can use a child band
Enter your text in the child band, and when the data is more than one page, place a portion of your data on the next pages.
You can have more than one child band.

Angular ui-grid - how to tell if I am on the last row

I'm using the latest version of Angular UI Grid and am struggling with how to determine if the focus is currently on the last displayed row of the grid.
The data array is not sorted the way it is on-screen, so I cannot use that info. I read that the visible row cache should be sorted as it is on-screen, but I think that might be related to the old ng-grid. At any rate, if I look at gridApi.core.getVisibleRows(myGrid) it still has the sorting as per the raw data.
I am currently handling the event gridApi.cellNav.on.navigate(newRowCol, oldRowCol). I can see the column and row that the user has the focus on, but I cannot see any values in this event (or elsewhere) that I can use to determine if the row is the last-displayed on-screen. I'd appreciate any tips!!
You should use gridApi.grid.renderContainers.body.visibleRowCache which is an array sorted the way the rows are visible on the screen. You can then check if the row is the last row with something like:
oldRowCol.row.uid == $scope.gridApi.grid.renderContainers.body.visibleRowCache[$scope.gridApi.grid.renderContainers.body.visibleRowCache.length-1].uid

How to create a Hierarchical menu in iOS?

In my application, I have a menu that is defined as follows. Each item on the menu is a node that has the following data attributes:
MenuText : (the text that would appear for that item)
isView : Whether this item is a leaf level item or not
subMenus : if isView is false, then there are multiple menu items under this attribute.
Thus, it is a tree structure that can go till any depth. The items in the menu can change periodically and hence the implementation has to be kept flexible. This data is stored in a plist file and read into an NSArray in the code (already implemented).
I now need to create a slide out menu on the left that will be populated by this data hierarchy. I have created the menu pane and added swipe gestures to it, all of which work fine. The menu has to be a collapsible one where clicking on one menu item expands the subViews below it. If the item clicked on is a view, then a new view is loaded on the rest of the screen with appropriate data.
The problem I am facing is the logic to populate the menu (which is a UITableView) from the NSArray data. The following are the two approaches I came up with.
Create a UITableView with as many sections as there are items at the top level of the menu. Then iterate through the menu items recursively. For each menu item that is not a view (i.e. it has subMenus), create a new section with number of rows equal to the number of subMenus under it. When I come across a menu item that is a view and has no further subMenus, add it as a row to the subsection created for the menu one level above it.
Create a menu with one section and as many rows as the number of menu items at the top level. When a menu item is clicked, insert rows under it to represent its sub-menus. When another menu item on the same level is clicked, collapse the previously expanded menu by deleting the inserted rows. When a menu item with no sub menus is clicked, the rest of the screen is populated with data.
I have tried both the approaches and not been able to go beyond the initial steps. For the first method, I understand that I need to add a UITableView as a part of UITableViewCells, which is good, but I need to do that recursively. For the second approach, I need to know the indexPath of each item clicked which can go to many levels.
I would like some suggestions here about which approach I should take and some guidance over how to go about it. Also, if there is any better way to do this, kindly advice. Thanks.
In my opinion, using UINavigationController is the easiest way. You can push as many UITableViews as you want.
If it doesn't fit your design requirement, you can try expandable UITableViews. There are few open sources:
JKExpandTableView
SDNestedTable
iOS-Tree-Component
Thanks for the responses. I ended up doing this using the following control:
Accordion for iOS
It has served my purpose beautifully and I posted it here so that someone with the same requirement may find it.
Take a look at TLIndexPathTools. It has a "Tree" extension that can do this. Try running the Outline sample project. The main task in adapting the sample project would be to write a recursive function to convert your array of nodes into an array of TLIndexPathTreeItem objects. All of the code in the controller:willChangeNode: method is examples of lazy loading and it doesn't sound like you'd need any of that.

UICollectionView is not giving right index path when moving into empty section

I've been working with a great bit of code LXReorderableCollectionViewFlowLayout (written by Stan Chang Khin Boon). It allows for moving items around in a UICollectionView
I have a collection view with multiple sections. The sections are using a header with several controls in them. I allow the user to create empty sections and drag items into these sections
I using the collection view to show multiple albums of photos. Each section correlates to a different album. Dragging a photo from "Album 1" to "Album 2" works fine when each album already has items in it.
But, if the album (section) is empty, I can't move objects into that empty section.
I think the problem is with "indexPathForItemAtPoint". This method provides the correct NSIndexPath if the section has items in it. But if it's empty, it always returns section = 0, row = 0.
When I cross the border from section "0" into section "1" the NSIndexPath theIndexPathOfSelectedItem goes to 0,0 (section, row). I would have expected it to go to 1,0.
The problem seems to be with "indexPathForItemAtPoint". It isn't taking into consideration that the section might be empty and just defaults to 0, 0 when I cross the border into a different (and empty) section.
Like I said earlier, if there are items already in section "1" then the indexPath is set correctly.
Any ideas on what I'm doing wrong?
I ended up placing a dummy (but invisible) item in the empty section. When I create a new section, I place a dummy value in the section. I make it invisible so that it doesn't show. Anytime I add a new item OR remove an item from a section I test to make sure that the dummy item is there.
IMPORTANT: If there is at least 1 real item in the section, I remove the dummy value. Otherwise, the collection list tries to draw it.
I'm sure there is a better way of doing this. If you know how, please post a new answer.
Hope this helps.

Resources