我得到了无限循环,就像它一遍又一遍地检查条件一样。我不知道如何调试它......这仅在模拟器中的设备中发生,它工作正常。
当我点击开关时,我在uitableviewcell中有UISwitch,它会改变它的状态......但是如果我慢慢滑动开关......如果条件被无限检查......下面是改变uiswitch时的代码......任何人都可以帮帮我..谢谢
“我已经设置了断点,直到它 [selectedNotification show];
返回到 if 语句”
-(void)notificationChangedForSymptom:(int)symptomIDNo withRemedyID:(int)remedyID isSelected:(BOOL)isSelected
{
if (isSelected == YES)
{
selectedSymptomID = symptomIDNo;
selectedRemedyID = remedyID;
[self scheduleNotification:remedyID];
NSLog(@"dictionary %@",activeNotificationDictionary);
if ([activeNotificationDictionary objectForKey:[NSNumber numberWithInt:symptomIDNo]] != nil)
{
UIAlertView *selectedNotification = [[UIAlertView alloc]initWithTitle:@"Reminder" message:@"Would you like to change the notification" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
selectedNotification.tag = remedyID;
selectedNotification.delegate = self;
[selectedNotification show];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:activeNotificationDictionary];
[defaults setObject:data forKey:@"dictKey"];
[defaults synchronize];
}
}
}
更新:-这是在 customTableviewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
notifyMe = [[RCSwitchOnOff alloc]initWithFrame:CGRectMake(330.0, 69.0, 66.0, 33.0)];
[notifyMe addTarget:self action:@selector(notification:) forControlEvents:UIControlEventValueChanged];
[self.RemedyCustomCellView addSubview:notifyMe];
}
}
-(IBAction)notification:(id)sender
{
if (sender == notifyMe)
{
if(notifyMe.isOn == YES)
{
toggle = YES;
if ([cellDelegate respondsToSelector:@selector(notificationChangedForSymptom:withRemedyID:isSelected:)])
{
selectedRemedyArcImage.hidden = NO;
[cellDelegate notificationChangedForSymptom:self.symptomIDNo withRemedyID:self.remedyID isSelected:YES];
}
NSLog(@"Notifcation ON");
}
else
{
toggle = NO;
if ([cellDelegate respondsToSelector:@selector(notificationChangedForSymptom:withRemedyID:isSelected:)])
{
[cellDelegate notificationChangedForSymptom:self.symptomIDNo withRemedyID:self.remedyID isSelected:NO];
}
NSLog(@"Notification is OFF");
}
}
}