我有一个段控制器,现在点击段 1 时,会出现一个视图,然后在第二段的点击上显示另一个视图,就在这个段控制器的下方。现在我想当这个段控制器所在的视图出现时,第一个段控制器视图随之出现,并且第一个段控制器按钮似乎被提前点击。
我可以通过以这种方式展示我的观点来完成这件事。但我正在做不必要的事情..请告诉我其他方式。
-(void)loadTest
{
if(!cabinInfoDetailsViewObj)
{
cabinInfoDetailsViewObj = [[CabinInfoDetailsView alloc]initWithFrame:CGRectMake(232, 188, 617,412)];
}
[self addSubview:cabinInfoDetailsViewObj];
[CabinInfoPopupSegmentControl setImage:[UIImage imageNamed:@"16.4_WhiteButton.png"] forSegmentAtIndex:0];
[CabinInfoPopupSegmentControl setImage:[UIImage imageNamed:@"16.4_GreyButton.png"] forSegmentAtIndex:1];
}
这是段控制器部分
- (IBAction)CabinInfoSegmentButtonTapped:(id)sender
{
if(CabinInfoPopupSegmentControl.selectedSegmentIndex == 0)
{
if(!cabinInfoDetailsViewObj)
{
cabinInfoDetailsViewObj = [[CabinInfoDetailsView alloc]initWithFrame:CGRectMake(232, 188, 617,412)];
}
[CabinInfoPopupSegmentControl setImage:[UIImage imageNamed:@"16.4_WhiteButton.png"] forSegmentAtIndex:0];
[CabinInfoPopupSegmentControl setImage:[UIImage imageNamed:@"16.4_GreyButton.png"] forSegmentAtIndex:1];
cabinInfoDetails.textColor = [UIColor blueColor];
cabinInfoLocate.textColor =[UIColor blackColor];
[cabinInfoDeckPlansViewObj removeFromSuperview];
[self addSubview:cabinInfoDetailsViewObj];
}
if(CabinInfoPopupSegmentControl.selectedSegmentIndex == 1)
{
if(!cabinInfoDeckPlansViewObj)
{
cabinInfoDeckPlansViewObj = [[CabinInfoDeckPlansView alloc]initWithFrame:CGRectMake(232, 188, 617,412)];
}
[CabinInfoPopupSegmentControl setImage:[UIImage imageNamed:@"16.4_WhiteButton.png"] forSegmentAtIndex:1];
[CabinInfoPopupSegmentControl setImage:[UIImage imageNamed:@"16.4_GreyButton.png"] forSegmentAtIndex:0];
cabinInfoDetails.textColor = [UIColor blackColor];
cabinInfoLocate.textColor =[UIColor blueColor];
[cabinInfoDetailsViewObj removeFromSuperview];
[self addSubview:cabinInfoDeckPlansViewObj];
}