Changing the UI on the fly - iOS - ios

As far as i know, Auto-layout supports both RTL and LTR for the current held device language. But i need to my UI elements to support LTR according to a language selection button . Is there any possible way to reload the UI using Autolayout?

Make two arrays as properties, holding the constraints for LTR layout and RTL layout.
Depending on the selected state you remove one set from the view and add the other.
It means doing programmatic auto layout but that's not really too bad. The guide provided in the docs is an easy read.

Related

Disable Right to left support on IOS 9?

I have a large multi language app that does not have auto layout yet. The app contains many default tableview cells. In Arabic the app stays left to right and only uses the arabic localized strings. Is there a way to turn off this new right-to-left support so that default tableviewcells and navigation controller buttons are not flipped?
I know this approach via autolayout... in autolayout you can disable right to left change by selecting particular constraint and in property inspector untick the lable which says respect language...

Xcode 7 what is the view "semantic" storyboard setting?

I see that iOS9 and xCode7 introduced a new field called "semantic" into storyboard config. A google search did not reveal relevant results on top.
What is the significance of the view semantic field?
There is a new internationalization support in iOS 9, which enables flipping of the interface from left to right and vice versa depending on the current system language. You can choose Arabic language to test it. Arabic is read from right to left, so the interface is flipped.
Here you can read the Apple's guide on it.
The property "Semantic" in the storyboard is a rule which allows the iOS to know if the view should be flipped or not. There are multiple options:
Unspecified - The default value for views. The view is flipped when switching between left-to-right and right-to-left layouts.
Playback - A view representing the playback controls, such as Play, Rewind, or Fast Forward buttons or playhead scrubbers. These views are not flipped when switching between left-to-right and right-to-left layouts.
Spatial - A view representing a directional control, for example a segment control for text alignment, or a D-pad control for a game. These views are not flipped when switching between left-to-right and right-to-left layouts.
Force Left-To-Right - A view that is always displayed using a left-to-right layout.
Force Right-To-Left - A view that is always displayed using a right-to-left layout.
Source - Apple's documentation

Auto Layout implementation in already developed app in Xcode 6

I have already developed an IOS app in Objective C, Xcode 6 in which I have disabled the auto layouts and size classes.
Is it now possible to use auto layout after having disabled it earlier?
If yes, how can I implement it? When I enable the auto layouts and size classes and I implement the constraint on the label, the background colour of the label changes to white. When I do this for other object types, they become invisible.
To answer your first question, yes: it is indeed possible to use Auto Layout in an app after having disabled it. Each Xcode project template just gives you an initial starting point – nothing is set in stone.
For the second question, the best way of implementing Auto Layout in an app is to just take it one view at a time. You don't need to go all-or-nothing with Auto Layout; it's possible to just use it in certain cases but use frame based layout in others. Start on smaller, easier views and go from there.
The last issue around background colors is a little trickier without having screenshots or code samples. I have had views disappear on me after implementing Auto Layout and the issue always boiled down to bad constraints. The best solution I can give there is to just do the usual view-debugging work (as in, printing frames and manually setting bright colors to see where views actually are) and figure out what is going wrong.
Having the background color change to white is interesting, though... Auto Layout should not be affecting that at all. It sounds like the background color got changed somehow while the constraints were being created.

iOS App Arabic Localization Issue

I am working on an application, where I have to implement arbic as well as english locale.
I have made seperate storyboards for both languages. Problem is autolayout constraints are automatically flipping my views. Is there anyway to stop auto flipping for arabic locale?
I want to design views myself for arabic.
Thanks
Constraints by default respect language direction, but you can turn this off by selecting the constraint, and then in the Attributes Inspector, unchecking the Respect language direction in the First Item and the Second Item pop down menus.
Note that that option isn't available for all constraints.

Can iOS's auto layout rearrange UI widgets

I have an app which has a different UI for portrait and landscape. I've heard wonderful things about Auto Layout but in all my readings it seems to handle simple cases, where UI widgets resize and reposition simply. In my UI UI widgets move. Is this a case where I should try and get auto layout to work or should I just make 2 xibs and be done with it?
You can see in the portrait version that the green element is below the magenta one, but it is above it and next to the orange one in the landscape orientation.
Sorry, one auto layout setting will not allow you to rearrange views like that. You could still use auto-layout for positioning and spacing, but you'll need two sets of settings.
You could still use one xib file and change the auto layout settings at run time, but most likely multiple xibs makes more sense because you'll be able to see and edit your UI WYSIWYG style.
Update
Also, take a look at iOS 9's new UIStackView.

Resources