나는 내 앱을 놀고 있었고 정말 빨리 UISwitch를 토글하고있었습니다 (누가 저항 할 수 있습니까?). 그래서 10-15 배로 빠르게 전환했는데, 스위치가있는 표보기 셀의 데이터를 포함해야하는 배열이거나 동일한 셀의 추가 사본 또는 단 하나의 사본 (올바른 경우)이거나 데이터가 전혀 없습니다. 앱이 정상 속도로 전환되면 제대로 작동합니다.UISwitch 여러 번 빠른 전환
나는이 시나리오가 내 사용자에게 실제로 일어나지 않을 것이라고 확신하지만, 왜 아직도 일어나고 있는지 궁금하다.
감사합니다, 테이야
편집 : 코드를 추가. 이 메소드는 스위치가 전환 될 때마다 호출됩니다.
-(void)saveOptionChanged:(id) sender
{
UISwitch *sw = (UISwitch *) sender;
//int tag = current.tag;
BOOL status = (BOOL) [sw isOn];
NSInteger tag = sw.tag;
NSInteger row1 = tag%1000;
NSInteger section1 = (tag - row1)/1000;
DiagDetails *temp = [preferences getDiagElementAt:section1 row:row1];
temp.ICD9Code= [temp.ICD9Code stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
temp.ICD9Desc= [temp.ICD9Desc stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"Adding %@ - %@",temp.ICD9Code, temp.ICD9Desc);
NSLog(@"tag = %ld, row = %ld, section = %ld",tag,row1,section1);
if(status) {
BOOL returnVal = YES;
returnVal = [currentPatient addICD9Code:temp];
if(!returnVal) {
UIAlertView *error = [[UIAlertView alloc] initWithTitle:@"Diagnosis add error" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[error show];
[error release];
[sw setOn:NO];
}
}
else {
DiagDetails *temp = [preferences getDiagElementAt:section1 row:row1];
[currentPatient removeICD9Code:temp.ICD9Code];
}
}
코드를 보지 않고도 말할 수 없습니다. 스위치는 무엇을합니까? – prendio2