0
所以我有一個開關,當它「開」我想CPPickerView切換到一個數組中的特定值。另外,如果pickerview再次移動,我希望開關移動到關閉位置。以編程方式更改CPPickerview選擇?
我知道如何獲取當週的當天,並試圖將pickerview選項切換到當前的星期幾。
如果我在這裏問一個這樣的廣義問題只是讓我知道,或者如果你需要更多的信息。
//CPPicker
self.daysOfWeekData = [[NSArray alloc] initWithObjects:@"Monday", @"Tuesday", @"Wednesday", @"Thursday", @"Friday", @"Saturday", @"Sunday", nil];
self.dayPickerView.allowSlowDeceleration = YES;
[self.dayPickerView reloadData];
#pragma mark - Horizontal pickerview
//DataSource
-(NSInteger)numberOfItemsInPickerView:(CPPickerView *)pickerView {
return 7;
}
-(NSString *)pickerView:(CPPickerView *)pickerView titleForItem:(NSInteger)item {
return daysOfWeekData[item];
}
//Delegate
-(void)pickerView:(CPPickerView *)pickerView didSelectItem:(NSInteger)item {
self.dayLabel.text = [NSString stringWithFormat:@"%@", daysOfWeekData[item]];
}
//Today's day date
- (IBAction)todaySwitchChange:(id)sender {
if (todaySwitch.on) {
NSLog(@"It is on");
} else {
NSLog(@"It is off");
}
}