我正在无限循环,就像它一遍又一遍地检查条件一样。我不知道如何调试它...这只发生在模拟器中的设备中它工作正常。
我在uitableview中有UISwitch 当我点击开关时它改变了它的状态......但是如果我慢慢滑动开关...... if条件被无限制地检查 ......下面的谎言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");
}
}
}