我的应用程序中有一个设置视图,它有几个按钮(实际上是UISwitch).如果选择其中一个开关上的"关闭"设置,我想立即隐藏第二个开关.可以这样做吗?
在日历中,当您创建新事件时,如果您点击启用了VoiceOver的全天单元格,Siri会说"全天开关按钮打开/关闭,双击以更改设置".实际上,双击将切换开关.此外,不可能只关闭切换开关本身 - 您必须与单元本身交互以切换开关,交换机本身不是可访问的元素.
在我的应用程序中,我使用标签和开关完全相同的设置.但是当我在启用VoiceOver时点击单元格时,它只读取标签,因此盲人用户不知道该单元格中有一个切换开关.如果他们点击开关本身然后他们可以与它交互,所以它与日历应用程序中的设置相反.
如何获得Apple实施的相同行为?我需要一些方法将开关组合到单元格中,以便VoiceOver在突出显示单元格时读取它们,然后当它们双击它时应该切换开关,我不确定如何完成设置.谢谢!
我正在使我的应用程序"通用"(在iPhone和iPad上使用),我已经找到了增加除UISwitches以外的所有东西的方法.有办法吗?
任何帮助是极大的赞赏.
也许有人可以告诉我如何在 Switch() 中设置 TrackWidth、TrackStrokeWidth、ThumbDiameter 的大小
Switch(
modifier = Modifier
.padding(end=16.dp),
checked = auto.mainAuto.value,
onCheckedChange = { auto.mainAuto.value = it },
colors = SwitchDefaults.colors(
checkedThumbColor = white_white,
checkedTrackColor = Accent_Blue,
uncheckedThumbColor = white_white,
uncheckedTrackColor = Disabled_Text,
),
)
Run Code Online (Sandbox Code Playgroud) 我有一个UISwitch
自定义内部UITableViewCell
(我调用的子类RootLabeledSwitchTableCell
).
单元格包含a UILabel
并且UISwitch
彼此相邻.
我有一个@property
调用keychainSwitch
指向此自定义单元格内的开关:
@interface RootLabeledSwitchTableCell : UITableViewCell {
IBOutlet UILabel *textLabel;
IBOutlet UISwitch *labeledSwitch;
}
@property (nonatomic, retain) IBOutlet UILabel *textLabel;
@property (nonatomic, retain) IBOutlet UISwitch *labeledSwitch;
@end
Run Code Online (Sandbox Code Playgroud)
在我的表视图委托中,我添加了一个在翻转开关状态时调用的选择器:
- (UITableViewCell *) tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat: @"%d:%d", [indexPath indexAtPosition:0], [indexPath indexAtPosition:1]];
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
switch (indexPath.section) {
case(kMyFirstSection): {
switch (indexPath.row) {
case(kMyFirstSectionFirstRow) …
Run Code Online (Sandbox Code Playgroud) 如何判断一个UISwitch
内部UITableViewCell
是否被轻敲?
我UISwitch
是在单元格内设置的(通用单元格),如下所示:
UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[cell addSubview:mySwitch];
cell.accessoryView = mySwitch;
Run Code Online (Sandbox Code Playgroud)
我试图检测这样的水龙头(但它不起作用):
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSUserDefaults *prefs;
if(indexPath.section == 1){
switch(indexPath.row)
{
case 0:
NSLog(@"Tapped Login Switch");
break;
default:
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
Dave DeLong建议我为每个交换机设置一个动作作为解决方案.所以我做了以下设置开关:
UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[mySwitch addTarget:self action:@selector(switchToggled2:) forControlEvents: UIControlEventTouchUpInside];
if(at_songs){
[mySwitch setOn:YES animated:NO];
}
[cell addSubview:mySwitch];
cell.accessoryView = mySwitch;
Run Code Online (Sandbox Code Playgroud)
以下是知道它被点击的时间:
-(IBAction)switchToggled1:(id)sender {
NSUserDefaults *prefs;
NSLog(@"Tapped Login Switch");
prefs = …
Run Code Online (Sandbox Code Playgroud) 我相信大多数人都熟悉UISwitch
iOS.他们现有的任何项目是否都试图在Mac上实现这样的功能?如果没有,一个人会从哪里开始制作一个?我经常看到它们,可以想到这么多用途.
提前致谢
我正在创建一个具有UISwitch的应用程序.我改变了拇指颜色以匹配背景(使用thumbTintColor
)并且移除了拇指上的阴影.结果是当拇指处于关闭位置时拇指消失.
有谁知道如何在拇指上添加阴影,或防止它消失?
正如Apple的文档所写,其UISwitch
功能setOn(on: Bool, animated: Bool)
不会发送动作.它在iOS 10之前工作正常,但它会在我在iOS 10中调用它之后发送动作.我在"ValueChanged"事件中调用它来强制切换回来,所以我把这个事件动作两次.这是iOS 10中的一个错误吗?
如何以UISwitch
编程方式在Swift中的tableView单元格中嵌入?我是那样做的
let shareLocationSwitch = UISwitch()
cell.accessoryView = shareLocationSwitch
Run Code Online (Sandbox Code Playgroud)