Как получить значение (выбранное состояние) из моих сегментированных элементов управления в tableviewcells? Когда я нажимаю кнопку «Получить состояния», она должна возвращать значение для каждого из сегментированных элементов управления. Я пробовал разные методы, но я не могу найти тот, который работает :(Получить сегментированное значение управления из tableviewcells
Моего кода до сих пор:
- (void)viewDidLoad
{
[super viewDidLoad];
tableData = [[NSMutableArray alloc] initWithCapacity:0];
tableData = [NSArray arrayWithObjects:@"First", @"Second", @"Third", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"StateCell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"StateCell"];
}
//Config cell..
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
NSArray *itemArray = [NSArray arrayWithObjects: @"1", @"2", @"3", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.frame = CGRectMake(110, 7, 100, 28);
[cell.contentView addSubview:segmentedControl];
return cell;
[[self tableView] reloadData];
}
- (IBAction)getStates:(id)sender {
// Ruturn the current selected statement, for the individual cell's segmentedcontrol..
// Ex. First = SelectedState 1, Second = SelectedState 0 & Third = SelectedState 2..
}
Так что я на самом деле прошу, что «Получить состояние "кнопка действие должно сделать ..
Спасибо за ваше время!
Вы сделали это самостоятельно? Или вы просто просите код? –
Привет. Я пробовал всевозможные методы. Так что код будет очень приятным! Мне всего 15, и я довольно новичок в развитии IOS;) –
Пожалуйста, добавьте код, который вы пробовали на свой вопрос, и подробно объясните, какую конкретную часть вы застряли, и что происходит не так. –