辅助功能:Voice Over不会在xcode中自动读取自定义nib中的任何内容

时间:2013-06-19 16:20:03

标签: ios xcode uiview accessibility voiceover

我正在尝试更方便地使用我的应用。我创建了一个使用以下代码添加到UIViewController的自定义UIView:

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

此代码调用自定义UIView:

My xib file

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

Setting accessibility to elements

但是当自定义视图出现在屏幕上时,Voice Over不会自动读取任何内容。我必须按下每个元素才能使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不会自动读取任何内容。

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

0 个答案:

没有答案