0
我正在使用此代碼獲取導航欄右側的三個按鈕,按鈕是可見的,但在此旁邊,我想從此三個按鈕圖像轉到下一個視圖,文本,視頻。想要從右鍵菜單轉到下一個視圖項目
NSArray *segmentTextContent = [NSArray arrayWithObjects:@"Image",@"Text",@"Video",nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
segmentedControl.frame = CGRectMake(13, 20, 150, kCustomButtonHeight);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.momentary = YES;
defaultTintColor = [segmentedControl.tintColor retain]; // keep track of this for later
UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
self.navigationItem.rightBarButtonItem = segmentBarItem;
if(segmentedControl.selectedSegmentIndex=0)
{
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
}
else if(segmentedControl.selectedSegmentIndex==1)
{
[segmentedControl addTarget:self action:@selector(segmentAction1:) forControlEvents:UIControlEventValueChanged];
}
else if(segmentedControl.selectedSegmentIndex==2)
{
[segmentedControl addTarget:self action:@selector(segmentAction2:) forControlEvents:UIControlEventValueChanged];
}
[segmentBarItem release];
//[modalBarButtonItem release];
}
return self;
}