Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用辅助功能标签访问表中的按钮_Ios - Fatal编程技术网

Ios 使用辅助功能标签访问表中的按钮

Ios 使用辅助功能标签访问表中的按钮,ios,Ios,我需要一种方法来获取日历中每个按钮的引用,以便我可以随时更改其背景图像。我想做: UIButton *button = [get_reference_to_button_using_Accessibility_label]; [button setBackgroundImage:image] 初始化按钮时,设置按钮的可访问性标签。我可以使用它们来获取每个按钮的引用并更改其背景色吗 for (NSUInteger index = 0; index < self.daysInWeek; i

我需要一种方法来获取日历中每个按钮的引用,以便我可以随时更改其背景图像。我想做:

UIButton *button = [get_reference_to_button_using_Accessibility_label];
[button setBackgroundImage:image]
初始化按钮时,设置按钮的可访问性标签。我可以使用它们来获取每个按钮的引用并更改其背景色吗

 for (NSUInteger index = 0; index < self.daysInWeek; index++) {
        NSString *title = [self.dayFormatter stringFromDate:date];
        NSString *accessibilityLabel = [self.accessibilityFormatter stringFromDate:date]; // I can probably use it to refer to this button??
        [self.dayButtons[index] setTitle:title forState:UIControlStateNormal];
        [self.dayButtons[index] setAccessibilityLabel:accessibilityLabel];
        NSLog(@"day buttons!! %@", self.dayButtons[index]);

        ...
for(整数索引=0;索引
能否使用
日期
在初始值设定项中生成唯一的(日历)整数,然后使用该整数在视图上设置标记

NSInteger myTag = [date timeIntervalSince1970];
[self.dayButtons[index] setTag:myTag];
然后,当您想要引用该按钮时,您只需要它的关联日期:

UIButton *myButton = (UIButton *)[self.view viewWithTag:[date timeIntervalSince1970]];

您知道您要查找的辅助功能标签吗?或者只需检查标题标签文本以获取快速参考。是的,假设我有辅助功能标签。因此,给定辅助功能标签(在本例中,字符串格式为NSDate)我可以获取一个与该辅助功能标签对应的单元格按钮对象吗?@IanMacDonald是否可以使用辅助功能标签获取对按钮的引用?谢谢!我认为这可能有用?但是否可以使用辅助功能标签获取对按钮的引用?我不知道如何使用辅助功能标签来设置视图,除了在所有视图上循环并测试有问题的字符串,或者在存储在属性中的字典中关联视图和标签。在我看来,使用标记似乎更优雅、更简洁。