Tôi có UISegmentedControl sau, mà tôi muốn được vô hiệu hóa:Làm cách nào để vô hiệu hóa UISegmentedControl?
-(void)displayCheckMark
{
titleSegmentedControl = [[UISegmentedControl alloc] initWithItems:nil];
[titleSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"symbolbg.png"] atIndex:0 animated:YES];
[titleSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"inwatchlist.png"] atIndex:1 animated:YES];
[titleSegmentedControl addTarget:self action:@selector(titleBarButtonChanged:)forControlEvents:UIControlEventValueChanged];
titleSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
titleSegmentedControl.frame = CGRectMake(100,0,100,30);
titleSegmentedControl.momentary = YES;
titleSegmentedControl.tintColor = [UIColor blackColor];
self.navigationItem.titleView = titleSegmentedControl;
[titleSegmentedControl setWidth:60 forSegmentAtIndex:0];
[titleSegmentedControl setTitle:symbol forSegmentAtIndex:0];
[titleSegmentedControl setWidth:30 forSegmentAtIndex:1];
[titleSegmentedControl setEnabled:NO];
}
Tôi không có nó được kích hoạt bất cứ nơi nào trong các mã. Tuy nhiên, tôi vẫn có thể nhấp vào nó và nó sẽ thực hiện hành động trong titleBarButtonChanged:
Làm cách nào để đảm bảo rằng nó không thể được nhấp?
Vô hiệu hóa các phân khúc cá nhân hoạt động. – DataGraham