I'm trying to mimic what the Google+ app does when a user clicks on a cell in the tableView. I realize this is a highly customized version of a tableView, but I'm wondering if anyone has any pointers on where to start. Most big features like this seem to have an opensource project where someone is already mimicking it, but I cannot find one for this. Thanks!
dispatch_async(dispatch_get_main_queue(), ^{
CALayer *layer = cell.layer;
layer.transform = CATransform3DMakeTranslation(-layer.bounds.size.width/4, 0, 0.0f);;
NSTimeInterval animationDuration =0.2;
// The block-based equivalent doesn't play well with iOS 4
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:animationDuration];
cell.layer.transform = CATransform3DIdentity;
cell.layer.opacity = 1.0f;
[UIView commitAnimations];
});
play with the transform you should be able to make it . use this in the cell will display function
The 'Feed' view looks like a UITableView with a customized UITableViewCell that has a cell.contentView of the UITableViewCell being animated with UIView animateWithDuration: or something in setSelected:animated: when the didSelectRow: on the 'Feed' view tableview is called.
If I were to make that customized UITableViewCell, I'd probably have two views depending on the situation: 'Setup A: the view for when it's being scrolled in the feed view' and a 'Setup B: view for when it's been clicked to show the contents of the post more indepth'
setup A would be a more normal UITableViewCell, but setup B would have the same header view of the user who posted (what you see when you're scrolling the feed view), but below that it looks like it has it's own UITableView (which animates after it's been clicked and loads all the users and their comments if there are any comments).
That's just what comes to mind initially -- Hope that's a start?
Related
In facebook'a new app, Pages, when you swipe down the menu appears at the top. The animation I am trying to do is the animation when you tap the settings button which is when each cell moves to the left one at a time, but very smoothly. How can I achieve such an animation without using Facebook's pop engine in Objective C ?
Bear in mind that each cell is probably a custom subclass of UIView (i.e. not UITableViewCell or other apple class) so you will have to design your UI carefully.
The animation, however, is easily achievable using the UIView class. Apple's documentation is a good place to start to learn about animation.
What you want is something like:
NSTimeInterval delay = 0.2;
for (UIView *myView in myViewArray) {
[UIView animateWithDuration:0.5 delay:delay options:UIViewAnimationOptionCurveEaseInOut animations:^{
/*
* This is where you set the properties you want to animate.
* If you're using AutoLayout (i.e. NSLayoutConstraint) you need to set the constant property of the relevant constraint, not the view's frame property.
*/
} completion:nil];
delay += 0.2;
}
This will provide you with animations that occur one after the other (0.2 seconds apart).
I have made a "pull-to-refresh" and when finished updating the inset is removed using animation block. However I'm getting unwanted animations in the custom uitableviewcell, see movie:
https://www.youtube.com/watch?v=rZcEBm_fTUc&feature=youtu.be
Watch carefully at the bottom. I found this:
How can I exclude a piece of code inside a core animation block from being animated?
But don't know how to use it, here is the code that I'm using:
id animation = ^{
//Remove the contentinset
[self.tableView setContentInset:refreshView.initialInset];
};
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionBeginFromCurrentState
animations:animation
completion:nil];
[refreshView endAnimation];
}
Thankful for any help on this matter!
I was not reusing my UITableViewCells correctly. Before i removed all subviews from the cell and added them again, which is the wrong way to do it.
By using "reuseIdentifier" for my different UITableViewCells and only instantiating the UILabels and UIButtons once the problem disappeared (along with a lot of other problems)
I have been researching this for the better part of a day now, and I am coming to the conclusion that it may not be possible. Here's what I am trying to do. I have a TableViewController, and in that I have a table view with one section. I have set the section header to contain a UIView, and I am leaving the default "sticky" behavior so the section header doesn't scroll with the rows. I want to introduce a button on the section header that when tapped will cause a second TableView to slide DOWN from the section header. Basically, I want similar functionality to the notifications window, but I want it to slide out/down from the table's section header.
Thus far, my best attempt involves redrawing the section header, and then calling [self.tableView reloadData], which results in a twitchy effect and the second tableViewController doesn't display correctly. My next thought is to actually use the second TableView as the UIView in the section header, and only display the footer of the second TableView until the user taps the header. Even if I do this, though, I still can't figure out how to create the slide-down transition.
Any help or ideas on this will be greatly appreciated.
To slide a View down from above, I finally settled on this code:
-(void) openView
{
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height);
}
completion:^(BOOL finished){
}];
}
-(void) closeView
{
[UIView animateWithDuration:1.0
animations:^{
loadingView.frame = CGRectMake(0,-40-self.view.frame.size.height,self.view.frame.size.width,self.view.frame.size.height);
}
completion:^(BOOL finished){
}];
}
When closing the view I start with -40 on the y axis because I needed an offset for my work. If you use this code you may need to play around with the values to get what you need. I hope this can point someone else in the right direction for a solution to their specific problem.
I want to make a UIView animate when it's being closed. I tried reading the following:
http://felipe.sabino.me/ios/2012/05/10/ios-uiview-transition-effects/
iPhone UIView Animation Best Practice
iOS UIView Animation CATransform3DMakeRotation confusion
However, I'd like to make it transition from the side of the screen, as per the image in the Google Chrome app.
Is there another animation that is set for this? I was not able to find it... I'm assuming it has to do with animateWithDuration or a CATransform...can somebody point me in the right direction for this?
[EDIT]
I used the below post for an answer as well as this post:
Setting a rotation transformation to a UIView or its layer doesn't seem to work?
I was able to add multiple animations as per below:
[UIView animateWithDuration: .2
delay: 0
options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{self.view.center = CGPointMake(self.view.frame.origin.x * 3, self.view.frame.origin.y * 2), self.view.transform = CGAffineTransformMakeRotation(M_PI_4/2);}
completion:nil];
Previously I was not aware you can add multiple animations so easily. That adds rotation as well as the linear movement together.
Animate your view so it moves offscreen/shrinks/expands/fades, then do the actual removal when the animation ends.
You can do this by altering the properties of the view (position/size/offset) between a beginAnimations/commitAnimations block. UIKit will then animate these properties over the time specified.
E.g something like;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.30f];
view.transform =
CGAffineTransformMakeTranslation(
view.frame.origin.x,
480.0f + (view.frame.size.height/2) // move the whole view offscreen
);
background.alpha = 0; // also fade to transparent
[UIView commitAnimations];
In the animation end notification you can then remove the view.
I've never run Chrome on iOS, so I have to try to guess what your screenshot is showing.
Does the animation go off the screen while shrinking and turning to one side?
And do you mean you want to animate a UIViewController, or a UIView? Are you closing a view controller?
If it's a view controller, how are you managing your view controllers? Are you using a navigation controller, or are you presenting a set of modal view controllers, or some other method?
I have data structured as a tree (and showed in UITableView) and I would like to show it the way it is usually done using UINavigationController and pushing child views on to the stack. The problem is that my UITableView (in an iPad app) takes only 1/6 of the screen (there is a UINavigationController that handles other fullscreen iPad screens in this app, so using NavigationController to control the levels of table is the good way).
Is there a simple way to get a good visual effect of changing the levels of TableView without using NavigationController? Right now I just change the data source and reload data, but that does something like a flicker on the screen (the user can't really see, that the structure of the data is tree-like).
I thought of creating a few TableViews and then just animating the resize (from full width to 0 the TableView that we are leaving, and from 0 to width at the same time of the another one) of a table just to make something like segue effect - but I am not sure if this is a good approach.
You can use reloadSections:withRowAnimation: with UITableViewRowAnimationLeft and UITableViewRowAnimationRight instead of a default reloadData. This will look like the push you are looking for.
Reference: http://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/reloadSections:withRowAnimation:
You can try this code (after you set the proper values:))
__block CGRect frame = tableView.frame;
[UIView animateWithDuration:0.5 animations:^{
frame.origin.x -=tableView.frame.size.width;
} completion:^(BOOL finished) {
frame.origin.x = yourViewThatContainsTheTable.frame.size.width
tableView.frame = frame;
[tableView reloadData];
[UIView animateWithDuration:0.3 animations:^{
frame.origin.x = 0;
tableView.frame = frame;
}];
}];
Basically if you are using subclasses of UIView you can use [UIView animateWith...] methods to perform simple animations or you can use CAAnimations/CABasicAnimation/CAAnimationGroup/CAKeyframeAnimation for more complex animations on subclasses of UIView.
If you want a custom transition for a UIViewController you can use CATransition.