Thursday, 15 August 2013

uinavigationcontroller - iOS get UINavigationBar's back button in order to set accessibility properties -



uinavigationcontroller - iOS get UINavigationBar's back button in order to set accessibility properties -

i have navigation controller stack 1 of views has dynamic title.

the view controllers , titles go this:

main --> itemstableview --> itemdetails title:main title: nn items title: details

because ios uinavigationcontroller sets text of "back" button title of previous screen, "back" button on details screen says "< nn items" nn dynamically changing number.

i'm trying ios ui automation, accessibility label / id of button set scheme it's button text. means accessibility label of button on details screen alter dynamically, , can't find scripts!

if reference uibarbuttonitem set it's accessibilitylabel or accessibilityidentifier code fixed string, can't figure out how this?

all of stuff i've been able find references setting button custom button via self.navigationitem.backbarbuttonitem or similar, when read property it's nil. haven't been able find out how get access standard item without replacing it. i'd prefer not replace button if possible

this bugging me well. i've been writing xcode 7 ui tests , trying come generic way of tapping on button without having replace custom button.

the next how solved xcode 7 ui tests - may able apply ui automation well.

i discovered (in terms of xcode 7 ui tests @ least) bar button item created scheme consists of 2 buttons entire thing button accessibility label of whatever title of button is, , arrow button accessibility label of "back".

thus, long there aren't other buttons on screen identified "back", button can accessed via accessibility label of "back". in case of ui tests:

[[app.buttons matchingidentifier:@"back"] elementboundbyindex:0]

here i'm getting first button can identified "back". case there ever 2 such buttons - arrow, or whole button (in case button's title "back"). since both of these buttons same, getting first 1 finds sufficient.

ios uinavigationcontroller uinavigationbar

No comments:

Post a Comment