UIImageView not being read by Voice Over - ios

I've got a set of UIImageViews contained inside of a UIScrollView. For some reason, when I go to have Voice Over read all the elements on the page, it does not read the ImageView like it should. I set up the UIImageView's accessibility info like so:
if (self.featuresModel.imageText) {
self.featureImage.isAccessibilityElement = YES;
self.featureImage.accessibilityLabel = self.featuresModel.imageText;
}
I've checked that the UIScrollView is not set to be accessible, so it's not intercepting the touches. It seems to show it will work in the simulator, when I click on the image it pops up the correct label and highlights the correct area, however, on a physical device, clicking or trying to read all elements on the page does nothing when it gets to the UIImageView.
Any ideas on how to remedy this issue?
Edit: The scrollView class is a custom subclass of UIScrollView that doesn't implement UIAccessiblity protocol directly, however, since it uses a UIScrollView as its underlying data structure, I don't think this should matter much, however, as I still don't know much about UIAccessibility I thought I should mention it.

Make sure you enabled the accessibility for your imageview on storyboard/nib.
IF you set the isAccessibilityElement to YES, the voice over highlights it and reads it. Again the accessibility for that element should be enalbled in nib.
IF you set the isAccessibilityElement to NO, the voice over doesnt highlights it and doesnt reads it, even the accessibility for that element is enalbled in nib.
Note: Voice over doesnt care about scrolview.It only care about the elements in the scroll view. You can change the order of the accessibility elements if you want.Or you can disable the accessibility for the elements in the scroll view.

Related

UITextView Scrolls to the right when it gains focus in Swift

Whenever I tap on my UITextView on my testing device, the text is pushed far to the right as demonstrated in the gif below.
I can't see why this behaviour is happening, within my Storyboard I have tried to disable scrolling and have applied constraints to ensure that the width of the UITextView is only ever the width of the device, yet this still happens. The UITextView has not been subclassed or had any additional attributes applied to it via code.
If anybody has had this problem before it would be great to get some insight around how I could remedy it.
EDIT Constraints for the text view.

NSTextView stops being able to scroll once new text is set

I have a TextView made in the Interface Builder;
It scrolls fine with its default text, but as soon as I programatically set the text to something else, it no longer scrolls.
I do not disable scrolling, and I have tried enabling scrolling (setScrollEnabled:YES), and user interaction (setUserInteractionEnabled:YES) both of which make no difference.
The things that I have found:
It scrolls with the default text showing
It doesn't seem to matter what text I set in it, it just stops scrolling as soon as it is set. I'm doing it programatically like this:
self.myTextView.text = #"any text"; (or [self.myTextView setText:#"any text"]; has the same effect.)
I have two other Textfield in the same View, one of which is using the View Controller as its delegate. The TextField in question is not using the View Controller as its delegate. None of the delegate methods set anything to do with scrolling.
Both of the other TextViews have their scrolling capability set to defaults. If I change the one that doesn't need it to no scrolling, it makes no difference to the problem.
The one that has the View Controller as its delegate continues to scroll after I edit it (non programatically) and this one continues to be able to scroll once the one in question freezes.
If I delete these two other TextFields, then the one in question works as expected, i.e. it scrolls after adding text.
Any thoughts?
Thanks.
Make sure your new text is long enough to be able to get scroll.
if text is just one line it wont scroll but if its larger then text area size then it will scroll its by default settings

What do these settings do in Interface Builder?

This is for a UIButton specifically. I understand that the alignment options pertain to the label inside the UIButton, but what does the 'content' settings do? They seem like they correspond to the setEnabled:, setSelected:, setHighlighted: methods of the UIButton class, however clicking Highlighted or Selected doesn't seem to change the button's behavior outside of interface builder. Also, what would be the use-case for having a button always show highlighted or selected?
There are several practical uses for these methods. As #MHUMobileInc. pointed out, it can be used for a game like Minesweeper. It can also allow you to use the button as a sort of switch, where the selected button has "ON" and the non-selected version has "OFF". It seems that Apple wants developers to shy away from this, and to use either UISwitches or a custom view. However, Apple does contradict itself in some of its apps.
These settings set the initial state of the UIButton- so if in your viewDidLoad you set it not selected nor highlighted, this Interface Builder setting will not be seen on screen when you run the app. If you want to ensure that these settings are kept, it might be easier to say so in code (viewDidLoad) rather than Interface Builder.
It may be easier not to use these settings too much. They can lead to confusion for you (the developer), other programmers who are working on the project (if any) and the user. Use the built-in UIKit views when it works and create your own subclasses when there is nothing that fits best for the situation.
The upper portion addresses the alignment of the content within the view. For example, if you have a large UIButton with an image that's smaller than the bounds of the button, by default the image will be centered vertically and horizontally inside the button. However, if you want the image to hug the left/right/top/bottom, you can set the alignment using those options.
All of these controls pertain to the UIControl, not UIButton, as indicated by the header in that screenshot.
Alignment refers to contentHorizontalAlignment and contentVerticalAlignment. Many controls return a fixed width or fixed height, or both, from sizeThatFits:. For example a UISwitch object has a fixed size, whereas a UISlider object has a fixed height. If you assign a frame to a control object that does not correspond to these fixed dimensions, these properties determine where in that frame the control interface should be drawn. Instances of UIButton do fill their frame, so the UIButton class interprets these properties differently to apply to the button's content, but the properties themselves are not specific to the UIButton class.
Similarly the selected, highlighted and enabled properties are defined by UIControl not UIButton, not all subclasses of UIControl utilise them.

Did receive memory warning when alloc UIButton and UILabel

This is the situation:
I've a UIScrollView (called A) that scrolls horizontally. For this scroll view the property pagingEnabled is setted to YES. On the right of the screen I've a UIButton, that's attached to self.view and doesn't scroll with scroll view.
When tapped, this button shows a UIView with another UIScrollView (called B) inside that scrolls vertically. This scroll view contains a list of UIButton and UILabel. Every UIButton as an UIImage as backgroundImage. I used UIButton instead UIImageView because in this way is easy to manage the touch event on the image. The UILabel contains a description for every image.
The problem:
For every page in A scroll view, I need to change the UIButton contained in the B scroll view, because every page has a different image list. So, in the scrollView:didEndScrollingAnimation scroll view delegate method I remove the old UIButton and the old UILabel from the view and I remove also from the NSArray in which they're contained.
The I create a new list of UIButton and UILabel, I add to self.view and insert in the array, with [array addObject:].
After a variable number of scroll the app receive a memory warning message and the will killed from the system.
I use ARC, so is almost impossible to understand if the old object are deallecated (and in any case would be very difficult because they are system objects).
Any ideas ?
What I would do in your case, is the same I recommend to others:
Use profile and analyse the difference between heaps. This way you are able to check the memory footprint of your application between each swipe.
For a basic tutorial of how to do it, you can check this. I know this is a bit vague and you would want a objective answer, but the thing is that, what you think is that the problem right now, might not correspond to the real issue in your application. If you need further help after analysing your heap, just edit your question and let us know.
And this is the original article I used, from Mr. bbum.

Showing scroll indicators on a UIScrollView when programmatically scrolling

EDIT: The crux of this problem is that scroll indicators do not show during programmatic scrolling, but I would like them to. My original question (provided below) assumed this had something to do with userInteractionEnabled, but it does not. The mention of a master and slave UIScrollView is also possibly distracting from my core problem (the need to show scroll indicators during a programmatic scroll). Apologies to those of you who answered or commented based on my misleading assumptions/info.
Possible Solution: The only way I found to do this was to use the fact that scroll indicators are instances of UIImageView and use a category on it to hack the alpha. This article shows the approach. It was then a case of using tags and scroll view delegate methods to turn the alpha permanently on prior to a programmatic scroll, and permanently off when the scroll is finished. This feels hacky though, so any further suggestions would be welcome!
Everything below this line is the original unedited question to provide context to users' answers and comments
Setting userInteractionEnabled in a UIScrollView object to NO appears to disable the scroll indicators upon programmatic scrolling. This happens even if you have self.showsVerticalScrollIndicator = self.showsHorizontalScrollIndicator = YES;
Is there any way to programmatically scroll the scroll view but still show the indicators?
(To provide some context: I have a slave scrollview that mimics a master scrollview by hooking up the scrollview delegate callbacks and passing the content offset to the slave scrollview. However, I don't want the user to be able to directly manipulate the slave scrollview, but I do want scroll indicators).
Instead of setting userInteractionEnabled to false try setting the UIScrollView's scrollEnabled property to false. The doc. says "When scrolling is disabled, the scroll view does not accept touch events" that should mean that you should still be able to programmatically scroll the UIScrollView. Hope this helps - Did not test it out let me know.
You could try putting a transparent UIView (alpha == 0.0) over your scroll view (but as a sibling in the view hierarchy, not as a subview). Set touchesEnabled to YES on the transparent view, and it will intercept touches heading for the scroll view.

Resources