Is it possible to figure out what part of the cell is visible from inside the cell subclass? - ios

In my cell subclass the user can slide the cell for actions, just like in Mail.app. However, the cells can be much larger than Mail.app, sometimes up to 1,000pt which means it requires the table to be scrolled to read fully.
This means that the normal strategy of simply centering the actions vertically in the cell will not work, as the vertical center could very well not be visible. So I want to display it in the vertical center of the visible area.
Is this possible to do within the UITableViewCell subclass where the sliding action is occurring? Figuring out where the vertical center of the visible area even is?

Related

How to set Table view cell to occupy entire screen?

I am working on a project to get custom news feeds from Bing news. I created a custom table view cell and populated various UI items in it. But I am having a hard time to make it occupy the entire screen, it starts from extreme left and ends on the right, leaving large gap from the right margin as show in the image. Can anyone help me out, how to correctly fix it with a detailed explanation of how constraints work in Table views and Tableview cells.
Here' what it looks like in the simulator
Remove previous constraints and add constraint to your UITableView like as shown in below image.
So you UITableView will have 0 margin from edges.
Create a UITableViewController. Just drag drop a TableViewCell into it. Add identifier for that cell and use it. By default it will occupy the whole screen.
In your case I guess you might have added constraints to UITableView. Here what you should do is pin your UITableView to Top,Bottom,Right & Left or make UITableView's width equal to SuperView.

How to set up a horizontal collection view w paging and a single cell centered on-screen with edges of other cells visible

I haven't worked with collection views a whole lot.
A client wants a horizontal collection view set up with paging enabled.
They want a single cell centered in the collection view, with the edges of neighboring cells peeking into the view to provide a visual cue that they can swipe to see other cells.
If I set up the collection view using paging and a default flow layout, as I page over each cell ends up shifted to the left a bit more.
I implement the UICollectionViewDelegateFlowLayout protocol's collectionView(_:layout:insetForSectionAtIndex:) method, I can set up section insets such that each cell is kept centered, but when I do that the neighboring cells don't appear, and ONLY the current cell is ever visible until you start scrolling.
I assume I need to do something with a custom flow layout, but I'm not sure what, exactly. Can somebody offer some guidance?
(I'm working in Swift 2.3, although I'm "bilingual", so answers in either Swift or Objective-C are fine.)

position custom cell in a tableview not fully showing a cell

Okay What i want to do is position a custom cell so that the cell looks like only a portion of it is shown in the UITableView. When you swipe it to the left it goes to a new viewcontroller that allows the user to add details for a new cell. My question is how do we position the UITableViewCell to show only a portion of it in the tableView?
What i want to do is position a custom cell so that the row is not shown fully like about 1/4th or 1/2 its actual length only in the table view
here is an app with the functionality i'm trying to implement this is the image url as i can't post images yet
http://a3.mzstatic.com/us/r30/Purple6/v4/01/16/ec/0116ec99-0206-d125-7d27-d5956b918635/screen568x568.jpeg
I want to implement my cells just like how they implemented their expenses in cells, the cell is positioned according to the amount in it ,if the amount is high the cell is placed further to the left else only 1/4th of the cell is shown(empty cell no expense )
Can we achieve this by making an imageview in a customcell and then changing the x-axis of the image view according to the amount entered in the cell? Thanks in advance
For this, I would do it this way :
For each of my model cell I add a state, in the delegate of UItableView i use heightForRowAtIndex to set the size depends of the cell's state.
To not show extra view (when the cell is cliped) use :
[myCellview setClipToBounds:YES];
I think it should do the tricks. Even if it's not the best way to do it!
Solved it i Just had to add a scroll view to the cell's content view and then add a view containing the color to the scroll view. So its coding is similar to the swipe deletion in 'UITablView'
https://github.com/TeehanLax/UITableViewCell-Swipe-for-Options
this repository helped me out, i only had to make a few changes otherwise that was it thanks for all your suggestions :)

How to allow UICollectionView to scroll in intervals of the cell width

I have a UICollectionView that scrolls sideways. When it is scrolled I want it to land on a multiple of the cell width. The cells are diamonds and must fit in a very precise location.
Example: If user scrolls, then the scroll will happen as normal (or maybe semi-paged) and then when it stops, make sure it stops at a multiple so the cell can be aligned with the diamonds.
Any idea how to approach this?

UITableViewCell Reuse issues with horizontal tableview

I have a slightly complicated system that I am having some reuse issues with, wanted to get some feedback. Basically it is a vertical tableview, and each cell contains another tableview that is rotated 90 degrees, so that each cell scrolls horizontally. Each horizontal cell is also set up to scroll infinitely with paginated responses from an API. I am having issues where cells are copying on top of each other when the vertical table is scrolled down. I have reuse identifiers set up correctly and in each of the horizontal tableviews I am running the following:
- (void)prepareForReuse
{
[_horizontalTableView reloadData];
}
If I turn off reusing cells the issue doesn't happen, but the vertical scrolling performance suffers. I am wondering if its possible that reusing cells in this type of a set up just isnt possible? Any experience with this is helpful. Thanks.
This is not a direct way to solve your issue, but I believe if you use a horizontal scroll view inside each vertical cell, you will have this done faster and with less weird behaviours. I also believe this is not a standard way, so weird stuff will happen.
All you do is set or extend the content size of the scroll off screen continuously to create an infinite scrolling behaviour. Create views within the scroll view pragmatically to simulate each cell. Hope this helps.

Resources