It seems that Xcode 12 is no longer supporting a default user interface style provided in the info.plist for iOS14. Is this a bug with the beta or is there any other way to provide this information without the need of overwriting every single element?
The following code did the trick
UIApplication.shared.windows.forEach { window in
window.overrideUserInterfaceStyle = .light
}
Related
Currently, CXProviderConfiguration localizeName is deprecated.
https://developer.apple.com/documentation/callkit/cxproviderconfiguration
let configuration = CXProviderConfiguration(localizedName: "Call")
=> 'init(localizedName:)' was deprecated in iOS 14.0
How can I set its localizeName now?
I want to show the name("Call") in the right-bottom.
If I understood correctly your question, you want to display a custom string below the button with your app icon in the CallKit UI.
Contrary to what I thought and wrote in the comment, the localizedName of CXProviderConfiguration, prior to iOS 14 was used as the label of the button mentioned above.
On iOS 14 and above, instead, is the Product Name that's used for that purpose. You can find it in the build settings of your target, and by default, it's equal to your target name. Keep in mind that it's also the string displayed below your app icon on the home screen.
I am working on a macOS app where I want to give users the ability to switch between light and dark mode.
For iOS apps, this can be done by simply overriding the UserInterfaceStyle of UIWindow. Like so:
window.overrideUserInterfaceStyle = .dark //.light
The problem: NSWindow doesn't have a UserInterfaceStyle property.
I have tried to set the NSAppearance
window.appearance = NSAppearance(appearanceNamed: NSAppearance.Name.aqua, bundle: nil)
without success. It returns me an error saying: "RunTimeThemeRefForBundleIdentifierAndName() couldn't find NSAppearanceNameAqua.car in bundle with identifier: ..."
I am stuck. Do you have any ideas?
Here would be a solution for iOS
Thanks!
I was on the right track!
window.appearance = NSAppearance(named: .aqua)
worked.
There is actually a guide to set the appearance of macOS apps from apple.
Note: This also works if you have all your content inside a NSPopover, since it too has a property appearance.
I know this is quiet simple and straight forward to disable autocorrection on iPhone and it worlds pretty much fine, but until now. Surprisingly, suggestion bar appear for text field even I have disabled it from storyboard and even programmatically.
self.textField.autocorrectionType = .no
Done that in sotoryboard as well.
But it does appear on iOS 13, not on previous versions and simulator.
There are many answers already for this one but none is working on iOS 13 so no need to mark the question as duplicate.
Cheers!
If you are using a Storyboard you can disable autocorrection on the attributes inspector (the down arrow icon) under the Text input traits. See the image below for details.
After a successful migration to swift 2.3 in my application, I found a font glitch.
I have an extension for UIFont where I change system font to my custom font.
In iOS 9 and earlier everything worked as expected. In iOS 10 it doesn't.
The problem was in self.fontName. Normally it should return "fontName" + suffix for style (ex:regular, bold, etc).
However in iOS 10 for regular the style, it doesn't return suffix only "fontName".
I googled to found why but couldn't find anything.
The problem is fixed but why this happens I don't know. Any idea?
Using font names has never been a good idea.
Use fontDescriptor and inspect the UIFontDescriptor's fontAttributes and symbolicTraits to obtain information on the font in question. You can then create a new descriptor with modified attributes and/or traits, and obtain a font with that descriptor using init(descriptor:size:).
I want to give the user the possibility to change the language in my app.
The way to do this is described here, in monotouch code to set the preferred language to Dutch and alternate language to English:
NSUserDefaults.StandardUserDefaults.SetValueForKey
(NSArray.FromStrings("nl", "en"), new NSString("AppleLanguages"));
You have to restart the application before this will take effect. But on the iPhone 4 the app does not restart when you close it, it is just hidden. Is there a way to force an app to restart after closing?
Thanks Dimitris. So changing the language at runtime is not that simple.
I found a solution which works in my case:
When the user changes the language I use the solution described by Mauro Delrio in "How to force NSLocalizedString to use a specific language". In monotouch:
string newLanguage = "nl";
myBundle = NSBundle.FromPath(NSBundle.MainBundle.PathForResource(newLanguage, "lproj"));
All strings will now be loaded in the selected language with myBundle.LocalizedString(...). Of course, everything which was already printed on a view is not yet translated. But I found an easy way to reset all views. In my app I use a MainTabController which looks like this:
public class MainTabBarController : UITabBarController
{
public override void ViewDidLoad()
{
Reset();
SelectedIndex = 2;
}
public void Reset()
{
ViewControllers = new UIViewController[]
{
new ViewControllerTab1(),
new ViewControllerTab2(),
new ViewControllerTab3(),
new ViewControllerTab4(),
new ViewControllerTab5()
};
}
}
So all I have to do is call Reset like:
((AppDelegate)UIApplication.SharedApplication.Delegate).MainTabBarController.Reset();
All current views are disposed and re-created in the correct language. Seems like a trick, but it is perfectly legal and documented, see Apple documentation for MainTabBarController viewControllers property. It even activates the same tab index as the one which was active, so for the user it seems that nothing but the language is changed.
Of course, any unsaved data in all views is lost, so if this is a problem, you have to find a way to save this before resetting.
No there is no way to restart an app. You can only force it to terminate when the users presses the home button by setting the property "UIApplicationExitsOnSuspend" in your Info.plist file to true.
The trick to use specific language by selecting it from the app is to force the NSLocalizedString to use specific bundle depending on the selected language ,
here is the post i have written for this http://learning-ios.blogspot.com/2011/04/advance-localization-in-ios-apps.html
and here is the code of one sample app https://github.com/object2dot0/Advance-Localization-in-ios-apps
As an additional note, to force the UIBarButtonSystemItem to change their locale, you have to add
<key>CFBundleDevelopmentRegion</key>
<string>nl</string>
to your info.plist. Just fire up TextEdit and place it somewhere. Hope this helps!