サブビューを繰り返し処理するのは大変な作業です) それを避けるようにしてください。信頼性が低いため、あまり良い方法ではありません。たとえば、カスタム セル UI を変更する場合は、サブビューを反復処理するメソッドを変更する必要があります。
次のことを試してください。
UIImage と 3 つの文字列 (名前、年齢、携帯電話番号など) を持つカスタム セルがあるとします。
カスタム セルに 3 つの関数を実装して、この値を次のように設定します。
MyCustomCell.h ... .h ファイル標準コード、最後に ...
@propert(nonatomic, strong) IBOutlet UIImageView *myImage;
@propert(nonatomic, strong) IBOutlet UILabel *myFirstLabel;
@propert(nonatomic, strong) IBOutlet UILabel *mySecondLabel;
@propert(nonatomic, strong) IBOutlet UILabel *myThirdLabel;
- (void)setUIimage:(UIImage *)_image;
- (void)setFirstString:(NSString *)_string;
- (void)setSecondString:(NSString *)_string;
- (void)setThirdString:(NSString *)_string;
MyCustomCell.m:
@synthesize myImageView, myFirstLabel, mySecondLabel, myThirdLabel;
- (void)setUIimage:(UIImage *)_image {
self.myImageView.image = _image;
}
- (void)setFirstString:(NSString *)_string {
self.myFirstLabel.text = _string;
}
- (void)setSecondString:(NSString *)_string {
self.mySecondLabel.text = _string;
}
- (void)setThirdString:(NSString *)_string {
self.myThirdLabel.text = _string;
}
最後に、tableView コントローラーで cellForRowAtIndexPath
[myCustomCell setUiImage:someImage];
[myCustomCell setFirstString:oneString];
[myCustomCell setSecondString:twoString];
[myCustomCell setThirdString:threeString];
このアプローチがお役に立てば幸いです。ご不明な点がございましたらお気軽にお問い合わせください