Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 8之后,UIView动画不起作用。如果屏幕上有其他更改,UIView位置将重置_Ios_Objective C_Iphone_Uiview - Fatal编程技术网

iOS 8之后,UIView动画不起作用。如果屏幕上有其他更改,UIView位置将重置

iOS 8之后,UIView动画不起作用。如果屏幕上有其他更改,UIView位置将重置,ios,objective-c,iphone,uiview,Ios,Objective C,Iphone,Uiview,我有一个旧的应用程序,它有一个UIView,一个mercury。无论何时出现反对票或赞成票,它都应该在0-100的基准上改变其状态,以显示当前的投票情况。问题是,当我更改屏幕上的其他内容时,例如标签中的文本,mercury的位置将重置为其原始位置(在.xib文件中确定) 它在iOS 7中运行得非常好 @property(nonatomic) IBOutlet UIView *mercury; -(IBAction)happyBtn:(id)sender { self.counter++

我有一个旧的应用程序,它有一个UIView,一个mercury。无论何时出现反对票或赞成票,它都应该在0-100的基准上改变其状态,以显示当前的投票情况。问题是,当我更改屏幕上的其他内容时,例如标签中的文本,mercury的位置将重置为其原始位置(在.xib文件中确定)

它在iOS 7中运行得非常好

@property(nonatomic) IBOutlet UIView *mercury;

-(IBAction)happyBtn:(id)sender
{
    self.counter++;
    self.positiveVotes++;
    if(self.show!=NO){
        [self newPosition:YES];
    }else{
        [self newPosition:NO];
    }
}

-(IBAction)peekBtn:(id)sender
    {
        if(self.peekCounter!=0){
            self.peekCounter--;
// * if I comment this out, the mercury's position is reseted
            //[self.peekLabel setText:[NSString stringWithFormat:@"Available peeks: %d",self.peekCounter ]];
            [self newPosition:YES];
        }else{
            UIAlertView *alertV = [[UIAlertView alloc] initWithTitle:@"No more peeks" message:@"No more peeks available" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertV show];
        }
    }

 -(void)newPosition:(BOOL)show
{

        CGFloat mod = 100/self.counter;
        self.pos = mod *self.positiveVotes;
        self.fpos = 400- ((300/100)*self.pos);
        NSLog(@"counter:%f, positive:%f, mod:%f pos:%f, fpos:%f",self.counter,self.positiveVotes,mod,self.pos,self.fpos);
        CGRect mercurybox = self.mercury.frame;
        mercurybox.origin.y = self.fpos;


        if(show==YES){

            self.mercury.frame = mercurybox;
            //self.tipLabel.text = [NSString stringWithFormat:@"%0.1f",self.pos];

        }
}

您是否有一些可能对您不利的自动布局约束?如果您使用的是自动布局,您应该通过更改约束来移动视图,而不是更改框架。我打开了“使用自动布局”,现在一切正常了!:)谢谢