Я пытаюсь повторно использовать код представления таблицы popover, чтобы при нажатии пользователем кнопки «Канада» отображались провинции Канады (Альберта, Британская Колумбия, ...); когда пользователь касается кнопки США, отображаются штаты США (Алабама, Аляска, ...). Проблема в том, что когда я нажимаю кнопку «США» после кнопки «Канада», первые 12 штатов США не отображаются в 13 провинциях / территориях Канады, которые по-прежнему отображаются.
Я следую за кодом здесь
http://www.raywenderlich.com/1056/ipad-for-iphone-developers-101-uipopovercontroller-tutorial
, но изменяя код setColorButtonTapped для получения массива, чтобы я мог повторно использовать код для разных массивов
- (IBAction)setColorButtonTapped:(id)sender withData:(NSArray *) data {
if (_colorPicker == nil) {
self.colorPicker = [[[ColorPickerController alloc]
initWithStyle:UITableViewStylePlain] autorelease];
_colorPicker.delegate = self;
self.colorPickerPopover = [[[UIPopoverController alloc]
initWithContentViewController:_colorPicker] autorelease];
}
[self.colorPickerPopover presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
_colorPicker.tableList = [data copy];
// I defined a property NSMutableArray *tableList
// I think the problem is with the way I copy the data }
Извините за кодирование.
Заранее спасибо за помощь.
Джо