A UIImageView animation was stopped by something - ios

I create a UIImageView with animationImages.
Like this :
The Code
The imageView execute perfectly most time怂But when I show a custom view which poped up using facebook's pop animation in common rootView,the imageView animation would be stopped. I do not konw is this wrong has something about pop.Does anybody can give me some suggestion?

First , the animation of images may ends while the popup is presented so setting animationRepeatCount to zero makes it loop again when it reaches final image
imageView.animationRepeatCount = 0;
Second you may start the animation again in viewDidAppear method
-(void) viewDidAppear
{
[self.imageView startAnimating];
}
Finally it's better to declare the imageView
var imageView:UIImageview!
out of viewDidLoad

Related

Once swiping on UIImageView with animation the animation stops

I have a UIImageView with animationImages and it works fine
self.imageView.animationImages = [self loadImages];
self.imageView.animationDuration = 15;
[self.imageView startAnimating];
I've added a swipe gesture that, in the selector of the swipe I want to do the following:
find the image that is currently shown
move to the next/previous image
continue the animation
Post your gesture recognizer action method.
It will take some tinkering, but it should be possible to do what you want to do.
I suspect that you will have to stop the animation, juggle the order of the images in the animation array, and then start the animation again. The image view should revert to the normal content image when the animation stops, so you might want to set the normal image to the image on which you stop if you get flickering when you stop the animation and restart it.

Custom UINavigationBar animation

I've subclassed UINavigationBar in order to set a custom background image.
I'm using it to initialize a UINavigationController with:
-(id)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass
The problem is that when new UIViewControllers get pushed on to the NavigationController stack, the title text animates in from the right across the background image in a way that looks a bit sucky.
Problem: How to tweak the animation so e.g. it fades in as it animates across.
The closest I've come is by creating a custom fade-up animation in the pushed/popped ViewController class. I use a NSTimer to trigger changes to the alpha of the titleView:
UILabel *titleView = (UILabel *)self.navigationItem.titleView;
...
-(void)setAlpha:(float)alpha
{
titleView.textColor = [UIColor colorWithRed:grayShade green:grayShade blue:grayShade alpha:alpha];
}
However, if I trigger this in 'ViewDidAppear' it's already too late and the fade-up starts after the new view has finished sliding in. I figured that I could trigger it in 'ViewWillAppear' but that this might lead to indeterminate and inconsistent timings on different devices. Am I right in this assumption and if so, how can I customize the animation in the way I want to?

Animate MapView around screen

I have this animation block:
[UIView animateWithDuration:10 animations:^{
CGPoint centerLeft;
centerLeft.x = self.leftMapPane.center.x - 100;
centerLeft.y = self.leftMapPane.center.y;
CGRect leftMove = CGRectMake(self.leftMapPane.frame.origin.x - 100, self.leftMapPane.frame.origin.x, self.leftMapPane.frame.size.width, self.leftMapPane.frame.size.height);
[self.leftMapPane setFrame:leftMove];
[self.leftMapPane setCenter:centerLeft];
}];
but for some reason although it gets inside the animation block, it doesn't move the mapViews I have around on the screen.
It should be noted that I'm not talking about moving the map but the view that contains the map, aka the mapview.
Any thoughts?
The animation doesn't work in viewDidLoad because at that point the views have been loaded into memory but have not been necessarily added to the view hierarchy. So when you try to animate the views it won't work.
Instead, put your animation call in viewDidAppear and it should work. This way you're sure the views you're animating are in the view hierarchy. I tried this in a sample project using your animation code and it worked fine.

UIView animatewithDuration - Remove Animation

I have a recursive UIView animatewith duration: delegate to run an animation. When the view disappears I''m supposed to stop this animation. [self.view.layer removeAllAnimation] doesn't seem to help. ANy other means to stop animation?
What about using the method [UIView animateWithDuration:animations:completion:] ?
You can check inside the completion block if the view has disappeared. If it hasn't - run one more animation iteration.
This solution i came across is based on the UIObject. I added the UIObject to an NSMutableArray on starting the animation. When I leave that view call for [NSMutableArray * removeObject]; inside viewDidDisappear.

fade in/fade out UISegmentedControl in XIB

I have a UISegmentedControl set up in my XIB. I want it to appear on viewDidLoad and if the user taps the area of the screen it's in, and then to disappear if the user taps it again or to fade out if the user leaves it alone.
In looking around for how to manage this I've found a lot of stuff about fading UIViews, but not as much on fading individual subviews, and little at all on fading elements in the XIB. I tried to adapt the UIView stuff but failed.
How can I make this work?
EDIT: Okay, I've got the appearance at viewDidLoad and the fade out working. But when the user taps the area where the UISegmentedControl is (now invisible because alpha=0), nothing happens. This is the code I'm using:
- (IBAction)tapInvisibleSegContr
//This is connected to the UISegmentedControl with the action Touch Up Inside. Until now, the segmented control has been at alpha=0 since fading after viewDidLoad.
{
self.segContrAsOutlet.alpha=1.0;
[self fadeMethodThatWorksInViewDidLoad];
NSLog(#"Yup, tapped.");
}
I'm not even getting the NSLog. I've got the action hooked up to the UISegmentedControl, with the action Touch Up Inside. What am I missing?
If it is resident in a xib, just put his alpha to 0, do the properly connections: an Outlet and an IBAction for value changed
Then in the viwDidLoad right after [super viewDidLoad] write:
[UIView animateWithDuration:1 animations:^{self.mySegOutlet.alpha = 1;}];
Inside the IBAction right after you code the answer before the last } write:
[UIView animateWithDuration:1 animations:^{self.mySegOutlet.alpha = 0;}];
This is the easiest method.
Bye
In the xib set your control's alpha to 0.0, then use UIView animation methods to animate its alpha to 1.0. For example:
[UIView animateWithDuration:1.0 animations:^{
self.segmentedControl.alpha = 1.0f;
}];
EDIT: To your problem with not getting the action called, try attaching it for the value changed control event - I don't think UISegmentedControl sends for touch up inside.

Resources