그래서 두 가지 문제가 있지만 둘 다 관련이 있습니다. NSTimer 질문
- 는 I는
NSTimer
버튼을 이용하여 클릭하면 진행 뷰를 이동시키는 "애니메이션"를 만들었다. 이 애니메이션은 버튼을 처음 두 번 클릭해도 괜찮 으면 작동하지만 그 후에는NSTimer
루프의 처음 시작부터NSTimer
루프의 끝까지 건너 뛰면서 프로세스의 속도를 높이기 시작합니다. 나는 누군가가이 문제점에 대해 들어 본 적이 있고 해결책을 알고 있는지 궁금해하고 있었다. 질문 1에서 같은 것을 만들었지 만
: 여기UItableViewCell
에 편집 버튼을 누르면 루프가 활성화됩니다. 편집 버튼은[self.tableView2 setEditing:NO animated:YES];
및NSTimer
scheduledTimerWithInterval
... (진행보기 애니메이션) 기능을 활성화합니다. 여기서 문제는 setEdit 애니메이션이 더 이상 움직이지 않게되어서 그냥 자리를 잡아 먹지 않는다는 것입니다. 다시 한번,이 문제에 대한 해결책을 아는 사람이 있습니까?
-(void)editTable{
[self.tableView2 setEditing:YES animated:YES];
iCount = 8;
iCount2 = 257;
forwardProgress = YES;
animationFlag = YES;
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.001f target:self selector:@selector(increaseAmount) userInfo:nil repeats:YES];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(cancelEdit)];
}
-(void)cancelEdit{
[self.tableView2 setEditing:NO animated:YES];
forwardProgress = NO;
animationFlag = YES;
iCount = 38;
iCount2 = 227;
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.001f target:self selector:@selector(increaseAmount) userInfo:nil repeats:YES];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editTable)];
}
-(void)increaseAmount{
float max = 38.0f;
float max2 = 257.0f;
float min2 = 227.0f;
float min = 8.0f;
if (animationFlag == YES) {
if (forwardProgress == YES) {
if (iCount <= max) {
iCount++;
// NSLog(@"iCount = %i", iCount);
}
if (iCount2 >= min2) {
iCount2--;
// NSLog(@"iCount2 = %i", iCount2);
}
if (iCount <= max) {
[tableView2 reloadData];
}
if (iCount2 >= min2) {
[tableView2 reloadData];
}
if (iCount == max) {
animationFlag = NO;
}
newFrame = CGRectMake(iCount, 33.0f, iCount2, 11.0f);
[tableView2 reloadData];
}else{
if (iCount >= min) {
iCount--;
NSLog(@"iCount = %i", iCount);
}
if (iCount2 <= max2) {
iCount2++;
NSLog(@"iCount2 = %i", iCount2);
}
newFrame = CGRectMake(iCount, 33.0f, iCount2, 11.0f);
if (iCount >= min) {
[tableView2 reloadData];
}
if (iCount2 <= max2) {
[tableView2 reloadData];
}
if (iCount == min) {
animationFlag = NO;
}
}
}
}
꼭 코드를 입력하십시오. 이러한 행동을 보여주고 공유하는 가장 작은 청크를 격리하십시오. 1. 후속 클릭이 이전 버튼을 취소하지 않고 버튼을 이동하는 데 더 많은 타이머를 만드는 것처럼 들립니다. 또는 타이머가 클릭 사이에 재설정되지 않는 일부 상태를 사용 중입니다 (예를 들어, 여유롭게 들어가는 가속화 요인이 있고 재설정하지 못하는 경우).) 2. 덜 확신 ... 애니메이션 트랜잭션을 관리하기위한 UIView 클래스 메서드를 호출하고 있습니까? – rgeorge