Blink or highlight multiple UITableView cells - ipad

Current situation: I have implemented drag-and-drop functionality feature where users can drag items from one place and drop on any allowed row in UITableView. For example, users can drag item and dropped only on first cell or first 3 cells. Other cells are invalid. This is working fine.
Question: With my implementation users are confused about where to drop item. I want to blink or highlight all cells where users can drop an item on demand(I mean first 3 cells would start blinking or highlighted when user has item to drop). In short is there anyway I can manually blink multiple cells whenever required and reset them to their original state later on.

I would suggest you to implement a blinking effect to the cell or its contentView in this case. In an animation block, you need to switch the alpha using a timer. You can get a sample code from this question which you can modify to put it in a timer and to apply on your cell.
[UIView transitionWithView:cell.contentView
duration:0.6f
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
animations:^{ cell.contentView.layer.alpha = 0.4f; }
completion:NULL];

Related

Move a button from one UITableViewCell to another with animation in Swift

I have a button and I want to keep track of which cell has the button with firebase. I can do this by putting the button in all cells and just make it visible in the one cell using firebase data. The part I'm stuck on is animating the button to move from one cell to another.
The only way I can think of is to put a delay on moving it from one to another, then have a separate animation happen. Then I think if I make the delay the same as the animation's duration then it will look like it just moved. I just thought of that while typing this but let me know if there's an easier/better way please!
This is a pretty tough thing to do, and animations can sometimes be one of the most difficult parts of mobile development. You aren't super clear on what your animation should look like, but since UITableViewCells each have their own contentViews I don't think directly animating the button from one cell to another is possible.
The best method I could think is to:
1) Draw a button on the screen at the location of the button you want to move
2) Hide the real button underneath
3) Animate this fake button over the tableview to the spot of the new, real button
4) End the animation and show the real button.
But you might have to block user interaction with the tableview while this happens to prevent them from scrolling and screwing up the animation...

How to avoid iOS UITableView animation to block user interaction with table

I have a timer that insert a new item on a tableview every 2 seconds, it is required that the tableview shows this new line insertion with an animation of 1 second, the problem is that the user interaction is blocked while the tableview insert animation is happening, I tryied to pass as option for the animation the constant UIViewAnimationOptions.AllowUserInteraction, but it did not worked. What I need is that the user can interact with the tableview, selecting cells, scrolling etc even during the animation sequence. Any ideias ? The code for the problem example is on github
https://github.com/munhra/TableAnimationProblem
This video shows the not desired behavior
https://www.youtube.com/watch?v=Jb7dnCv5wXw&feature=youtu.be

Allowing selection while reloading UITableView section

I have a basic tableview with section headers that contains cells. A cell either has a checkmark visible or not. When the user selects the cell, it toggles the checkmark, and if all items in that section has the checkmark visible, additionally the section header is greyed out.
I trigger the UI update in tableView:didSelectRowAtIndexPath: by first updating the model and then call reloadSections:withRowAnimation:UITableViewRowAnimationAutomatic on the relevant section.
The problem is that when animating the change (duration about 0.3 s), the user cannot select another row until the animation is done. It is a common usage scenario, wanting to check a number of items in batch. I also absolutely want to animate the change.
The documentation states that one can configure a UIAnimation using UIViewAnimationOptionAllowUserInteraction to remedy this, but since I'm not using a manual UIAnimation but only calling UITableViewRowAnimationAutomatic, I don't know how to accomplish this.
Is there a way to allow the user to select (and initiate animations) on other cells while such an animation/reload is ongoing?
Note
It's tricky to get a custom section header to redraw/animate, the only way I managed to do it is by first reloading the affected section, and then immediately reloading the table – the latter to hide a flicker that appears otherwise.
If I only reload the single affected row, there is not animation on the section header – it just changes.
I ended up disregarding that the section header does not animate, the user experience is more severely affected by not being able to quickly toggle several items in the list.

how to drag or drop multi uitableveiwcells on ios?

I want do drag a lot of selected cells and recorder them in my app.But I don't know how to do it.It seems apple just let u to drag one that what I have done it.
idea?
If it is ok to require that the selected cells are contiguous, then you can cheat by replacing them with a single tall cell.
EDIT:
For noncontiguous, the lazy solution would be to let the user select any cells, then after they drag and drop one of them, just move all the other selected cells right below it.
You could experiment with UITableView and see if it will let you animate out the other selected cells (with deleteRowsAtIndexPaths:withRowAnimation:) as soon as dragging is detected (possibly with UITableViewDelegate's tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:). You could also see if it will let you redraw/resize the cell when it begins dragging - then you could make it look like a z-layered stack or totem pole them into a tall cell while dragging.
Of course I'm assuming all the selected cells will share the same destination position. I can't wrap my head around noncontiguous sources to noncontiguous destinations in one drag-n-drop. If the user drags down 3 slots, does that mean you add 3 to the positions of all the selected cells? What if that takes a cell out of bounds? Even if you decided on some rules for odd cases like those and actually implemented this monstrosity, it could never be user friendly.
There is no easy way out. You need to handle the animation and movement by yourself.
Maybe you can take a copy of the cells you want to move and show an animation of moving to the destination.
When animation stops change the datasource.

iOS Development - Round Rect Buttons move down for sub menu

I have spent about 3 months now trying to figure out a problem and have finally turned to help. I have a menu with 5 round rect buttons. I want to know if theres a way I can make it so when I click the first button, the other four move down, to create space for a submenu under the first button. The same for the second, third, fourth, and fifth button. At the same time however, I want to make it so if the first button is clicked, the other four move down, and say the third one is clicked, four and five move even more down, and a scroll view launches when they can no longer all be displayed on the screen at once. Thanks in advance for all help :).
You can in fact do this. Here is an example for you. The jist is that you make a new IBAction which movies the coordinates when you press the button. So, if you have your method for what happens when you press the button, just add this to it:
button.frame = CGRectMake(button.frame.origin.x, (button.frame.origin.y), button.frame.size.width, button.frame.size.height);
As for changing where the buttons move, make a method like that and just add to the coordinates in order to move it. For example, if you wanted to move the above button up 150 pixels, you would do this:
button.frame = CGRectMake(button.frame.origin.x, (button.frame.origin.y - 150.0), button.frame.size.width, button.frame.size.height);
See what I did there? You just add or subtract from the frame to move the buttons where you want them to go.
I think you should put them all inside a tableView instead of a UIScrollView, (which is a scrollView itself) and override the heightForRowAtIndexPath methods according to your will. You may have to write a custom UITableViewCell for this and have a property to understand whether the cell is selected or not and switch it inside the didSelectRowAtIndexPath. Use tableView's beginUpdates and endUpdates methods at the end of the didSelectRowAtIndexPath to animate the movement of other subviews automatically.
You can also write animations for that by changing the origin of the UIButtons to move them, but I have tried it and with that number of subviews it becomes really messy, believe me. To see examplary code with dynamic row height and only one selectable cell you can have a look at: https://stackoverflow.com/a/13293380/936957. To enable multiple selection you can either have a NSMutableArray at the viewController/ UITableView's delegate or put a property of your custom UITableViewCell, like I've said before, both should work fine.

Resources