Change accessibilityValue for tweet entities on iOS using TwitterKit

ios
fabric
twitterkit
embeddedtimeline

#1

Hi! I’m new to the Fabric forum and iOS development in general.

I’d like to be able to change the accessibilityValue for images in each tweet in a timeline. I have found the TWTRTweetEntity.h file where it suggests that accessibilityValue should be overrided by subclasses, but I am not sure how I might be able to set these individually from TwitterKit. I will keep on researching and hopefully find an answer, but if anyone has a suggestion of a place to start, that would be quite helpful :slight_smile:

Many thanks,
Mike


#2

Hey! I haven’t gotten a response yet so thought I would reach out again. Is the accessibilityValue of images something that can be changed in TwitterKit? If so, how might one do it?

Hopeful that this question gets answered for the sake of Accessibility developers!

Mike


#3

Hey @wintersRM4,

Thanks for reaching out on this. Can you share a bit more information about how you’re looking to use this or display these? Is it on specific tweets or an entire timeline or something else altogether?

-Mike


#4

Thanks Mike. Yes, I can.

Basically, if you use VoiceOver on the TWTRTimelineViewController, you hear “Image Attachment” when you flick to an image. This string is in the Localized.strings file. This is not a description of the image, but really just says that there is an image there. Instead, I would like to be able to change this string to something more descriptive. I have found that the TWTRTweetEntity.h file has an “accessibilityValue” string, and I think that means if I change it I can access it for each tweet, I can update it.

Thanks very much,
Mike


#5

Gotcha, thanks @wintersRM4, very helpful. The altText of an image has been added to the REST API, but isn’t yet available via Twitter Kit. https://blog.twitter.com/2016/accessible-images-for-everyone We’re working on changing that in Twitter Kit, but in the meantime, if you want that now, using the REST API may be a better option for you.


#6

Thanks! I heard about altText being available for images on Twitter, and am looking forward to seeing that in the future.

In the meantime, I am exploring using image recognition to automatically create altText, and was just curious how I might leverage “accessibilityValue” property in the TWTRTweetEntity.h for each tweet.

How would that work?

Thanks again,
Mike


#7

Hey! Sorry if I wasn’t clear before. I’m still quite new.

Are developers able to change/update the accessibilityValue for images in TwitterKit? If so, how?

E.g.
TWTRTweetEntity.accessibilityValue = “A person walking a dog”

Thanks,
Mike


#8

Hey @wintersRM4,

Sorry for the delay in getting back to you. I just sent you an email to chat further about this.

-Mike


#9

Okay, here’s how I have found to be able to do it:

`
class ViewController: UIViewController, UITableViewDelegate, TWTRTweetViewDelegate{

    // Create a TWTRTimelineViewController elsewhere. You will need to set its table view delegate:
    timelineViewController.tableView.delegate = self

    // Now, when the cells are loaded with TweetViews, this function will be called 
    // as part of the UITableView 
    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        cell.subviews[0].subviews[0].subviews[1].accessibilityValue = "whatever"
    }
}