2

我正在尝试让我的应用程序更易于访问。我创建了一个自定义 UIView,它使用以下代码添加到 UIViewController:

emergenteTiempos *emer = [emergenteTiempos shared:self.view];
[self.view addSubview:emer];

此代码调用自定义 UIView:

我的xib文件

我在使应用程序可访问中读到,您必须取消选中容器的可访问性,在我的例子中,包含所有元素(UILabel,UIButton)的 UIView,但您必须单独检查这些元素的可访问性。所以我这样做了:

设置元素的可访问性

但是当自定义视图出现在屏幕上时,旁白不会自动读取任何内容。我必须按下每个元素才能让 Voice Over 说出这个元素的标签。

我希望 Voice Over 在视图出现时自动发音所有字段。我尝试了很多东西,例如:

@implementation MultiFacetedView
- (NSArray *)accessibleElements
{
   if ( _accessibleElements != nil )
   {
      return _accessibleElements;
   }
   _accessibleElements = [[NSMutableArray alloc] init];

   /* Create an accessibility element to represent the first contained element and initialize it as a component of MultiFacetedView. */
   UIAccessibilityElement *element1 = [[[UIAccessibilityElement alloc] initWithAccessibilityContainer:self] autorelease];

   /* Set attributes of the first contained element here. */
   [_accessibleElements addObject:element1];

   /* Perform similar steps for the second contained element. */
   UIAccessibilityElement *element2 = [[[UIAccessibilityElement alloc] initWithAccessibilityContainer:self] autorelease];

   /* Set attributes of the second contained element here. */
   [_accessibleElements addObject:element2];

   return _accessibleElements;
}

/* The container itself is not accessible, so MultiFacetedView should return NO in isAccessiblityElement. */
- (BOOL)isAccessibilityElement
{
   return NO;
}

/* The following methods are implementations of UIAccessibilityContainer protocol methods. */
- (NSInteger)accessibilityElementCount
{
   return [[self accessibleElements] count];
}

- (id)accessibilityElementAtIndex:(NSInteger)index
{
   return [[self accessibleElements] objectAtIndex:index];
}

- (NSInteger)indexOfAccessibilityElement:(id)element
{
   return [[self accessibleElements] indexOfObject:element];
}
@end

但是 Voice Over 不会自动读取任何内容。

你可以帮帮我吗?非常感谢!

4

0 回答 0