Need help with text animation within UITableViewCell - iphone

I'm trying to implement a simple text animation in a custom UITableViewCell without having to go into editing mode which automatically brings up the delete button on the right. What I'm trying to accomplish is that when the label is updated by a button within the UITableviewcell, the text in the label is updated but with some smooth animation like sliding to the right since the updated text is prepended to the string. Any sample code would be great. thanks

I'm assuming the text is in a UILabel, which is a subclass of UIView, and therefore can be animated using core animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[myTextLabel setText:newText];
[UIView commitAnimations];

Related

Smooth out resizing table cells during reload on rotation

I have a project that includes a table that is dynamically created and formatted without using IB. The issue is, that the table needs to change both values and size during a rotation. However, the resizing is choppy and occurs suddenly during the animation. Currently I'm using the didRotate method, and in that method I'm calling the reload method in order to resize it. Should I be using a different method to do this, or is there anyway to at least smooth out the resizing?
Edit: I'm trying to use the replacement/resizing within the willRotateToInterfaceOrientation:, or possibly the two step animation. However, these methods are never called, is this due to the view hierarchy (the view I'm trying to resize is part of a split view)?
Do you tell the didRotate method to use animation when making the changes? For example, here is a code snippet that makes a flip transition. The key is to use the "beginAnimations" and "commitAnimations" to tell the iPhone how to handle those changes. The code in between describes the changes. When the "commitAnimations" is called, the changes are magically animated.
[UIView beginAnimations:#"leftPortrait" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:leftView cache:YES];
[leftWebView setFrame:CGRectMake(0, 0, 384, 916)];
[UIView commitAnimations];
Hope this helps.

How can I fade out text on a cell when I press edit button?

I would like to make my text label on a cell fade out when I press a button.
I tried pointing the label I want to make fade out, but it just work for only last cell.
And I found out that
-(void) willTransitionToState:(UITableViewCellStateMask)state
is the way to solve this problem, but I don't know how to use.
Do I need to make a new class that is subclass of UITableViewCell class?
Any help will be appreciated. Thank you!
Have you tried using UIView's animations?
That would be something like this:
// Where you want to make the label fade out
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3]; // in seconds, up to you
cell.textLabel.alpha = 0.0;
[UIView commitAnimations];

How can we turn views like turning a page in an iphone application?

Is it possible to turn a view slowly like turning a page? When i swipe from right to left, the current view will turn and the next view will be shown. And from left to right, the previous view will come slowly as we move the finger.
How can I do it? Any ideas??
You should add and remove subviews from your view by detecting the touch movements, using the animation transtion styles:
UIViewAnimationTransitionCurlUp //for removing views (vice-versa)
UIViewAnimationTransitionCurlDown // for adding views (vice-versa)
like:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[self.view addSubview:nextView];
[UIView commitAnimations];
You should customize above according to ur needs.
Hope this helps.
Thanks,
Madhup

Using of a single view to display different content on flip

I am trying to add a flip on row did select of every section.The flip side view should display the content of the selected section. I have tried to understand the apple transition tutorial but its tough to get.
Any simple application related to it .
Have you looked at the Apple Sample code? That is pretty well laid out and has a flip animation. If you create a default utility project, that code has pretty much nothing but flip code in it.
Generating a flip animation is very easy. You simply remove your main view (in your case the UITableView) and add your new view to the superView all inside a UIView animation block:
// start the animation block [UIView beginAnimations:nil context:NULL];
// Specify a flip transition
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[myAppsWindow removeSubView:myUITableView]; // obiously replace these views with the correct views from your app.
[myAppsWindow addSubview:mybackView]; // you should build this view with your details in it.
// commit the animations. The animations will run when this invocation of the runloop returns.
[UIView commitAnimations];

UITableViewCell Custom Drawing and Animating when Entering Edit/Reorder Mode

I am trying to do something very similar to this post. Starting with Atebits Fast Scrolling in Tweetie post I have a UITableView subclass that does all of it's drawing in the drawRect: method of it's contentView. This works perfectly and is super fast. What I am trying to do now is animate the transition from editing to not-editing.
An example of what I am trying to achieve would be a situation with some text right aligned in the cell. When entering edit mode, the contentView shifts right to allow room for the editing control but the text shifts offscreen on the right as well. If I simply call [contentView setNeedsDisplay] in layoutSubviews I can readjust the right aligned text but it just jumps to it's new position.
How can I get the transition to animate?
Your layoutSubviews should look like this:
-(void)layoutSubviews {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
/* Change offsets here. */
[UIView commitAnimations];
}
You may also need to add to applicationDidFinishLaunching:
[UIView setAnimationsEnabled:YES];