English 中文(简体)
无休止的 an灭
原标题:Infinite animation not being interrupted by home button

我有几门主谈,主要看法是,我肯定地把以下方法划入这几类:

- (void)hover:(NSNumber *)upDown {
    int sense = [upDown intValue];
    [UIView animateWithDuration:0.8 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
                     animations:^{                        
                         CGRect frame = self.frame;
                         frame.origin.y += (sense==1?1:-1) * 5;
                         self.frame = frame;
                     }
                     completion:^(BOOL finished){ 
                         [self hover:[NSNumber numberWithInt:(sense==1?0:1)]];
                     }];             
}

它发挥了巨大作用,但在该装置中,当家纽顿受到压力时,该套半电灯(最终通过多次在家纽顿停工)和与其他纽州的任何互动停止运作。 在任何其他情况下,即,只要我不报家 but,我可以通过控制人、报警所等......和模拟者采取行动。

任何想法?

UPDATE: The culprit seems to be the shadow I m applying to the views I m animating

self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOpacity = 1.0;
self.layer.shadowRadius = 5.0;

这似乎造成某种间接费用,只影响到无法进入背景状态的人?

任何人都遇到这种情况?

<><>UPDATE: 最后,我决定删除这部法律,并将Quartz的阴影带进去:方法。 我怀疑这一问题可能与“i”在进入背景模式之前所穿的阴shot和在受约束之外对层的阴影,但它只是一个gues子。

最佳回答

从根本上说,问题必须涉及这种获得四舍五入和阴影的方式:

[self.layer setCornerRadius:radius];

self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOpacity = 0.2;
self.layer.shadowRadius = 5;
self.layer.shadowOffset = CGSizeMake(0, 10);

阴影超越了观点框架,而进入背景状态的“灰色”进程似乎与估算时一样。

正如我在更新时提到的那样,我rid开了这段话,并利用Quartz来在框架中塑造一个阴影。 在如何做到这一点方面,有许多职位,但在此,进展是:

-(void)drawRect:(CGRect)rect
{
   const CGFloat *cComps = CGColorGetComponents([UIColor blackColor]).CGColor;
   CGContextRef context = UIGraphicsGetCurrentContext();

   CGFloat center = rect.size.width / 2.0;
   CGFloat radius = center;

   CGContextBeginPath(context);
   CGContextSetShadowWithColor(context, CGSizeMake(0, 10), 4, [UIColor colorWithWhite:0     alpha:0.1].CGColor);
   CGContextAddArc(context, center, center, radius, 0, 2*M_PI, 1);
   CGContextSetRGBFillColor(context, cComps[0], cComps[1], cComps[2], 1.0);
   CGContextFillPath(context);
}

NOTE: I set the height of the view to +15px to accommodate the shadow at the bottom.

希望会帮助一些人。 这无疑使我一度mad。

问题回答

我最近谈到这一问题,这一职位在查明罪犯方面令人难以置信。 然而,简单地说,在地下层放风就足以防止冻结。 (你还应将分化Scale与主要屏幕尺寸相同的装置。)

我所有的阴影层都相对静态, were子不断消化,因此,YMMV。

您的标准影子补充代码:

layer.shadowColor = [UIColor blackColor].CGColor;
layer.shadowOffset = CGSizeMake(0, 1);
layer.shadowOpacity = 0.5;
layer.shadowRadius = 1.0;

这是你需要补充的:

layer.rasterizationScale = [[UIScreen mainScreen] scale];
layer.shouldRasterize = YES;

我的第一项想法是,你应在你的档案中执行一个BOOL(请你停下来)。 接下来是:

- (void)hover:(NSNumber *)upDown {
    if(!stopGoing){
        int sense = [upDown intValue];
        [UIView animateWithDuration:0.8 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
                     animations:^{                        
                         CGRect frame = self.frame;
                         frame.origin.y += (sense==1?1:-1) * 5;
                         self.frame = frame;
                     }
                     completion:^(BOOL finished){ 
                         [self hover:[NSNumber numberWithInt:(sense==1?0:1)]];
                     }];
    }  else {
        // do something else
    }           
}

之后,在你与纽芬兰联系的国际行动中,我这样做:

-(IBAction)myButton:(id)sender{
    stopGoing = YES;
}

这应有效制止掠夺行为,而不会过分入侵。





相关问题
images sliding continuously with <table> and jQuery

I m trying to write a little test page that circulates images through a window (see image). I have colored boxes inside a table (gray border), with each box being a element. <table id="boxes" ...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Disable Windows 7 touch animation in WPF

In Windows 7 when you touch the screen there is a short animation that occurs at the touch point. In my WPF app I want to display my own touch points, without showing the one supplied by Windows. ...

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...

Visual State Manager VS Animations in WPF

There is a lot of talk about the simplicity of Visual States and the transitions between them in WPF/Silverlight. I have the need to generate animations dynamically at runtime, to animate the ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签