ios 中滑块、开关、分段控件、操作表和警告的常用函数

对于SLider通过value属性可以得到当前滑块的值

 UISlider *slider=(UISlider*)sender;
    self.sliderLabel.text=[[[NSString alloc] initWithFormat:@"%f",slider.value] autorelease];

对于UISwithch 控件,on属性可以判断出当前值,通过setOn函数设置当前滑块的状态

 UISwitch *whichSwitch=(UISwitch *)sender;
    BOOL setting=whichSwitch.on;
    [self.leftSwitch setOn:setting animated:NO];
    [self.rightSwitch setOn:setting animated:YES];

对于分段控件,属性selectedSegmentIndex可得到当前选择的分段

UISegmentedControl *segmentControl=(UISegmentedControl *)sender;
    NSInteger segment=segmentControl.selectedSegmentIndex;

操作表常用函数

 UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"are you sure?" delegate:self cancelButtonTitle:@"no way" destructiveButtonTitle:@"yes,i'm sure" otherButtonTitles:nil];

第一个参数是标题,第二个参数表示操作表的委托,如果是nil,则不做任何特殊处理,如果是self,则会调用本地-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex 函数,接下来是取消按钮的标题,nil是结束符

警告的常用语句
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"title" message:msg delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil];
        [alert show];

控件状态
 每个iphone 有四种不同的控件状态,并且任何时侯只能处于其中一种,普通状态是默认状态,highlight状态是值该控件正在被使用的状态,禁用状态是值控件被关闭时的状态,选中状态用于只是该控件被选中。




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值