How make UICollectionview appearing at specific section - ios

My problem is that I couldn't find the way to appear specific section of UICollectionview.
For example, 5 sections exsisted and I want to make 3rd section appearing at the beginning.
But 1st section only appeared and could not find the method to choose the section I want to show.
If anyone knows the way to solve this problem, please tell me how to solve it.

If you don't want to modify your datamodel to order sections, and show '3rd section' as '1st section', then you can use
scrollToItemAtIndexPath:atScrollPosition:animated: on UICollectionView.
You can pass [NSIndexPath indexPathForItem:0 inSection:2] assuming you have items in that section.

Related

Table header view is swiped to the left when deleting a cell

First off, sorry if this is a duplicated question but after reading several posts with similar issue, I wasn’t able to find a clear solution.
The problem is what the title states: I have a pretty basic tableview, with only one section and a tableheader. When I delete one row, the table header also gets swiped to the left at the same time with the row being deleted.
I guess the solution is to return false in canEditRowAtIndexPath when I know it is the header calling, but I don’t know how to differentiate it from the rest of rows.
I tried tableView.cellForRowAtIndexPath but didn’t work, I guess it is because the header cell is not really part of the tableview as the normal cells are. In fact, I don’t know how to get the indexPath of my header cell. I also thought about tagging the header cell but, again, I don’t know how to get it back in canEditRowAtIndexPath.
Many thanks in advance!!
This may happen if you are using an UITableViewCell instead of an UIView in viewForHeaderInSection method. Please verify it.
If you have only one section and you don't really need a sticky header, you could also add the UIView to the tableView.tableViewHeader property. Please check https://stackoverflow.com/a/5442005/3211512 for an example.
I think, allo86 is right. Your header may be a UITableViewCell. However, I would suggest a little different approach. If you are having only one section then set an UIView on top of your Table view(outside of the table) but if you are going to have multiple sections, then set UIViews as headers accordingly for any section for which you want to have a header.

Submenus in UITableView

I am building an app that uses a side menu, within that side menu is a UITableView displaying some text. When you click on one of those, it takes you to another ViewController. I searched the internet for it but didn't find something useful. My question is: how to make a "submenu" inside the tableview, so that when you click on it, it needs to dropdown and show more options.
I don't have any idea how to do this, so a little help would be really appreciated!
Thanks
You may use sections for building a submenu structure. You can overwrite viewForHeaderInSection for each section for which you don't want to display the section header and return an empty UIView object with a size of (0.0, 0.0) or even null. (I never tried returning null/nil myself.)
For each menu on the highest level you have exactly one corresponding section and each of them has just one row. They may or may not have header views.
For the menu that you want to display as submenu you set the header view of the related section accordingly and then have one row for each item of the submenu.
Unfortunately this allows for a 2-level menu heirachry only. But on the upside everything you need is already sort of build-in into cocoa touch.
Perhaps this could possibly help you achieve what you are looking for:
Expandable Sections UITableView IndexPath SWIFT
You may have to have a good look through the code but it should set you on the right track.

UITableViewCell resort without whole table reload

I now have some table with some custom cells in it. It' can be scrolled, cells provide some information and can interact with user with some buttons and so on.
Is where any way to resort the cells with some animation without whole table reload?
for example I have cells with tags 1, 2, 3, 4, 5 - placed as I wrote here. I want to resort it to become 2,5,1,3,4 for example - and user must see the cells moving to it's new place - but without table reload. Now I have to reload the table - so there is no any visual animation and to user it can be hard to understand what there is go on...
Maybe this question will help you:
UITableView animate row reordering upon sort
You probably cannot use the tag for each TableCell, but I cannot see how you get your data for your cells so can't help you much there. If you use a model, you could add a field to define the sorting order.
Hope this helps you in the right direction!
I complete with my own question, thanks to Laura for provide me help where I found the way to do what I want. The main point of it - to use
[_tableView moveRowAtIndexPath:indFrom toIndexPath:indTo];
for it. There is exist some not easy things here with indexPaths of items currently not visible on screen, but main thing - cell move - os ok.

Is there a option to add a new row in shinobi grids?

First of all i am using shinobicontrols for developing interactive UI controls (Grids) for iOS using Objective c and please don't suggest me some other controls as an answer because i need to use only this.
I am half way stuck while using this control. i have downloaded demo code for grids provided by shinobicontrols (trial for 30 days). from : http://www.shinobicontrols.com/shinobigrids/product-tour/get-started-quickly-and-easily/
I was able to reorder rows and columns, edit contents of cell, re size column width by pinch gesture and much more.
But i couldn't add a new row or column to the existing grid. Just wanted to know whether this can be achieved.
Thanks in advance.
Edit the datasource (add/remove) item and just do [grid reload];
I think this should do.
The above answer seems to be correct. Adding my views Shinobi grids can be considered as UITableView cells, If you simply change the data source array of the tableview and call [tableview reloadData], number of cells displaying on the view will also change. There is no option to add a row still.
Look at this one. It is in alfa stage, but it will be quite a powerful in month or two, I would say. Any suggestions are welcome and it's free, of course. Number of rows and row content is fully controlled from delegate, so it is dynamic.

UITableViewCell- controlling movement

When editing my UITableView, I give the option to move cells to reorder the data. However, The top two cells in the table are cells that give information about all of the cells in the table, and I dont want the user to be able to move information cells into that section. Here is a picture of the problem:
The user shouldn't be able to drag the cell titled 'This is bad!!!' into the section with the 'Total:' and 'New Group...' cells. Is there a way to control this functionality? I haven't seen a delegate method that does this, but I could have missed one.
Edit: oops! I just saw that someone else has asked the same question on SO, so I'm going to post the link and close this question. Thanks #fzwo for your help.
How to limit UITableView row reordering to a section
tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: from UITableViewDelegate is what you're looking for.
In your concrete case, you could also display the header information in the actual tableView.tableHeaderView. This scrolls like an ordinary cell, but isn't a cell. It would probably also make sense from a UI perspective, because it is something different than your ordinary cell content.

Resources