ITeye博客

UISwitch 初始化

修博龙泉 · 2012-09-25 18:54 · ios开发学习相关 · 移动开发 · Markdown

1.UISwitch的初始化
UISwitch *switchView = [[uiswitch alloc] initWithFrame:CGRectMake(54.0f, 16.0f, 100.0f, 28.0f)];
2.设置UISwitch的初始化状态
switchView.on = YES;//设置初始为ON的一边
 3.UISwitch事件的响应
[switchview addtarget:self action:@selector(switchaction:) forcontrolevents:uicontroleventvaluechanged];

在cell中添加uiswitch

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = ; if (cell == nil) { cell = initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } if(==0){ cell.textLabel.text=@"新消息通知"; }else if(==1){ cell.textLabel.text=@"成员可邀请"; }else if(==2){ cell.textLabel.text=@"是否公开"; }

    UISwitch *switchview = initWithFrame:CGRectZero]; switchview.tag = ; ; cell.accessoryView = switchview; ; return cell;

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。