2013-06-25
展开全部
楼主,看下面的代码,[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]可以通过监听UISegmentcontrol的:UIControlEventValueChanged事件来进行处理。[mw_shl_code=c,true]NSArray *buttonNames = [NSArray arrayWithObjects:@"Button01", @"Button02", nil];UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:buttonNames];segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]-(void)segmentAction:(id) sender{ switch([sender selectedSegmentIndex]) { case 1: label.text=@"AAAA"; break; case 2: label.text=@"BBBB"; break; default: break; }}[/mw_shl_code]
展开全部
[self.segmControl addTarget:self action:@selector(switchingView) forControlEvents:UIControlEventValueChanged];
- (void)switchingView
{
switch (self.segmControl.selectedSegmentIndex) {
case 0: {
}
break;
case 1: {
}
break;
}
}
监听的事件为:值改变(UIControlEventValueChanged)!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询