У меня есть UISegmentedControl
UIBarButtonItem *flex = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]autorelease];
bottomSegmentedControl = [[UISegmentedControl alloc] initWithItems:nil];
[bottomSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"messages.png"] atIndex:0 animated:YES];
[bottomSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"news.png"] atIndex:1 animated:YES];
[bottomSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"chart.png"] atIndex:2 animated:YES];
//bottomSegmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Messages",@"News",@"Chart", nil]];
//bottomSegmentedControl.tintColor = [UIColor blackColor];
[bottomSegmentedControl addTarget:self action:@selector(segmentedControlChanged:)forControlEvents:UIControlEventValueChanged];
bottomSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
bottomSegmentedControl.frame = CGRectMake(0,0,300,30);
bottomSegmentedControl.momentary = NO;
[bottomSegmentedControl setSelectedSegmentIndex:0];
UIBarButtonItem *segButton = [[UIBarButtonItem alloc] initWithCustomView:bottomSegmentedControl];
Когда я прохожу программу, [bottomSegmentedControl setSelectedSegmentIndex:0];
не вызывает событие UIControlEventValueChanged, где я делаю некоторые вещи в segmentedControlChanged:
Раньше это работало в iOS 4.3, но не в iOS5. Как я могу решить эту проблему?