I have an image in a cell's imageView, but If I scroll the uitableview up so that that particular cell goes off of the screen, then let it come back down, the imageView disappears.
How can I fix this?
The left column is the tableview untouched, the middle column is the tableview pulled up, the right column is the tableview released
As Kevin mentioned, your problem may be in the way you set the image. Are you creating an imageView and assigning it to the cell's imageView property or the image inside the property? without looking at the code, I would suggest checking what happens when the cell is created. in the cell == nil case. Hope it helps.
Related
I have two collection views. One at the top and one at the bottom. On selecting a cell, I want to move it to the top collectionView by animating the cell just like this,
I can add and delete cells in a conventional way. But can anyone tell me an approach to follow specifically for this animation?
I figured out a way. But still suggestions are welcome. I am taking a step by step approach to achieve this animation in didSelectRow.
Populate destination collectionView datasource and insert new item (Keep it hidden for now.)
Duplicate the selected collectionViewCell and store it in a variable, dummyView.
Make the collectionViewCell background to grey and hide the textLabel.
Add the duplicated dummyView onto the same frame(w.r.t. self.view) as the collectionViewCell.
Animate it to move to the destination cell.
Unhide the original destination cell and remove dummyView from the superView.
Hope anyone reading this will understand. Feel free to put a comment if not :)
Scenario:
I have a programatically created UICollectionView with flow layout inside which a cell contains a UIImageView and a UILabel on it.Now,On Long pressing on UIImageView,a cross image should comes on top right of the UIImageView and on tappig on it, The entire cell should be deleted.I have done some research on this.But it will me more helpul if someone share their ideas ...
Add a tapGestureRecognizer to the UIImageView
set the tapGestureRecognizer tag equal to indexPath.row so that you can determine the cell thats need to updated and deleted
I have UITableView with background image and then I scroll it I have parallax effect like background imageView scrolls too. Problem is that then my image finished I have tableView background. Is it possible to make infinity imageView? Like then I go through image then starts this one image from beginning.
In next few days I will add lib thay solved it and creates parallax effect under tableView
https://github.com/bizibizi/TableView-Parallax-Background
Can you show me how are you placing that image behind the TableView? I guess the hierarchy in the storyboard should be
UIView -> UIImageView -> UITableView
The size of the UIImageView and the UITableView should be the same. So when you scroll up and down the UITableViewyou could see the image in the background.
But please explain your scenario abit more so that I could suggest you something appropriate.
What Hanny means is that you need to have the tableView on top of imageView ordered in the stack of the parent view's subviews. What you can also do is stack two tableviews on top of each other, and add a touch event that moves both table view's scroll views. The image table view would contain cells that are the size of the whole view frame.
I have custom UITableViewCell and manage selection of my cells. When the cell is selected and the checkmark is presented, the cell Content View width shrinks and my labels with trailing constraints move to the left. How can I effectively avoid the content move?
I did not want to set the constraints to leading as I have flexible tableview width and they are right aligned. When I want to update label's constraints in code via its IBOutlets I went into trouble as I return multiple subclasses of UITableViewCell in cellForRow: and I got unrecognized selector error in didSelectRowAtIndexPath: when trying to set constraints in code. Any elegant solution? Thanks.
I had a similar (actually, the exact) problem, where the checkmark would push everything to the left.
- EDIT:
A few hours after my original answer, I realized it's a really simple issue.
This push to the left is a constraint pushing the contentView of the cell. So?
Connect the constraint from the item on the right (like the i button), to the cell itself, not its contentView.
- Original answer (the actual answer is on top, this is for the record):
I just realized there's a very simple solution. I had a button that was pushed left when checkmark was on and I had to keep a constraint to keep it in place (so that 'uncheck' won't move the button to the right). It was hard-coded 'width' from the right and overall just bad practice. Never mind that I could not 'get' that checkmark 'width' to do this dynamically.
Solution?
Hold a constraint from the left.
That's it. I have a label too, so in my case: Constraint from the button left to the label (so they won't overlap) and from the button-left to left content-view. Basically, whatever moves on the right does not really 'reaches' the left side (rather have everything 'sitting' on the right).
This behavior is by design.
The simplest way to get the behavior you want is to set an empty accessory view on every cell which will move all the content to the left the same distance as the checkmark.
How about putting the checkmark in there all the time, and just playing with the alpha / transparency?
if checked
{
cell.accessoryType = .checkmark
cell.tintColor = cell.tintColor.withAlphaComponent(1)
}
else
{
cell.accessoryType = .checkmark
cell.tintColor = cell.tintColor.withAlphaComponent(0)
}
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 :)