2010-12-02 13 views
2

会議コールの詳細を表示するカスタムテーブルビューセルがあります。セルのコンストラクタの本体は以下の通りです:UIオートメーションを使用してTableViewCell要素にアクセスする

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString*) reuseIdentifier { 
if(self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]) { 
     self.contentView.isAccessibilityElement = YES; 
     self.contentView.accessibilityLabel = @"Blah"; 

     conferenceNameLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 
     conferenceNameLabel.adjustsFontSizeToFitWidth = YES; 
     conferenceNameLabel.font = [UIFont systemFontOfSize:14]; 
     conferenceNameLabel.isAccessibilityElement = YES; 
     conferenceNameLabel.accessibilityLabel = @"Name"; 
     [self.contentView addSubview:conferenceNameLabel]; 

     conferenceDateLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 
     conferenceDateLabel.adjustsFontSizeToFitWidth = YES; 
     conferenceDateLabel.font = [UIFont systemFontOfSize:14]; 
     conferenceDateLabel.isAccessibilityElement = YES; 
     conferenceDateLabel.accessibilityLabel = @"Date"; 
     [self.contentView addSubview:conferenceDateLabel]; 

     recurringIconView = [[UIImageView alloc] initWithFrame:CGRectZero]; 
     [recurringIconView setContentMode:UIViewContentModeScaleAspectFit]; 
     recurringIconView.isAccessibilityElement = YES; 
     recurringIconView.accessibilityLabel = @"Icon"; 
     [self.contentView addSubview:recurringIconView]; 

     [self setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; 
} 

return self; 

}

UIオートメーションを使用している場合、私はアクセシビリティラベル「何とか」を使用してコンテンツビューにアクセスすることができます。しかし、私は自分のラベルやImageViewにアクセスできません。 UIオートメーションを使用してこれらのUI要素を取得できない理由は何ですか?

答えて

4

スクリプトの中で、あなたがlogElementTreeを(使用して、各セル用のアクセシビリティ階層をログアウトすることができるはずです):

cell.logElementTree(); 

これらのサブビューは、彼らのアクセシビリティラベルとともに、その記録されたツリーに表示されます。

あなたが何らかの形で彼らのラベルで、これらの要素に対処できない場合は、ビューを兄弟のリストにそれらの相対的な位置によってそれらをつかむことができる必要があります:

var firstLabel = cell.elements()[0]; 

私はUIオートメーションおよび例を示して歩きます私のcourse on iTunes Uにこのようなテーブルビューをどのようにテストするかについて説明します。

+0

私はあなたのコースの資料をチェックしなければならないかもしれません、多分 "AHAの瞬間"があり、私は何かばかげていることを実感しています。 –

+0

私は要素ツリーを記録しようとしましたが、UIオートメーションは、セルに長さ1の要素リストがあり、その単一の要素が名前が会議コールの名前と日付であり、値がnullであるUIAElementであることを報告します。 –

+4

@Jonathan - これは、表のセルがアクセシビリティコンテナのように見えることが原因です:http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/iPhoneAccessibility/Making_Application_Accessible/Making_Application_Accessible.html% 23 // apple_ref/doc/uid/TP40008785-CH102-SW3。適切な数のラベルとそれらのラベルの配列を返すには、カスタムテーブルセルのUIAccessibilityContainerプロトコルメソッドをオーバーライドする必要があります。ただし、視覚障害のあるユーザーへのアプリケーションのアクセシビリティが低下する可能性があることに注意してください。 –

関連する問題