how to move simple view in self boundary of simulator of iphone infinitely without animation in objective c?

StackOverflow https://stackoverflow.com/questions/22523943

문제

I want to move my UIView of size (x=50,y=50) in the boundary of simulator screen means rectangular without animation infinitely.

도움이 되었습니까?

해결책

To moving view continuously in your simulator boundary you have to put logic there is no predefined method without animation. if you are using animation then below given link is useful. How to repeat animation from current state not from startingstate? or without animation the below code will help you. And yes please note that **

  • pos

** is a object of CGPoint class and you don't have to allocate it simply declare in interface.

- (void)viewDidLoad

{

 pos  = v1.center;
NSLog(@"POSITION === %f",pos.x);

 [NSTimer scheduledTimerWithTimeInterval:0.05
                                 target:self
                               selector:@selector(rotateBoundary)
                               userInfo:nil
                                repeats:YES];

[super viewDidLoad];


 //[self performSelector:@selector(rotateBoundary) withObject:self afterDelay:5.0];
// Do any additional setup after loading the view, typically from a nib.

}

-(void)rotateBoundary {

if (pos.x>=20 && pos.x<=290 && pos.y==25) 
{      
    NSLog(@"Top left to right.");
    pos.x+=5;
    v1.center = pos;
    NSLog(@"pos.x   ===  %f",pos.x);
}
if(pos.x >= 290 && pos.y<=430)
{
    NSLog(@"Right top to down.");
    pos.y+=5;
    v1.center = pos;
    NSLog(@"pos.y   ===  %f",pos.y);
}

if(pos.y == 430 && pos.x>=20) 
{
    NSLog(@"Down right to left.");
    pos.x-=5;
    v1.center = pos;
    NSLog(@"pos.x   ===  %f",pos.x);
}
if (pos.x <= 20 && pos.y>=25) 
{
    NSLog(@"Down left to top.");
    pos.y-=5;
    v1.center = pos;
    NSLog(@"pos.y   ===  %f",pos.y);
} 

}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top