I'm writing a tvOS app using Xcode 9.2, targeting tvOS 11.
I have a UIProgressView and I'm trying to set it's style to .bar but Xcode says ".bar is not available".
How can I use the .bar style for the UIProgressView on my tvOS app?
The style bar of UIProgressView is only defined in the iOS SDK. It is defined as __TVOS_PROHIBITED in UIKit:
typedef NS_ENUM(NSInteger, UIProgressViewStyle) {
UIProgressViewStyleDefault, // normal progress bar
UIProgressViewStyleBar __TVOS_PROHIBITED, // for use in a toolbar
};
Also described like that in the documentation:
https://developer.apple.com/documentation/uikit/uiprogressviewstyle/1619835-bar
Related
I'm trying to make my iPhone apps (targeting iOS 15 and above) fully compatible with iOS 16 without success!
I don't know how to have NavigationView for iOS 15 and NavigationStack for iOS 16 in the same piece of code.
The code above isn't accepted by Xcode:
if #available(iOS 16, *) {
NavigationStack {
} else {
NavigationView {
}
From: SwiftUI NavigationView/Stack if available iOS 15/16
I guess that creating a custom container, as suggested by #timmy, will be the only solution. But I don't know how to proceed.
What's the solution then?
Personally I wouldn't use NavigationStack unless I would target iOS 16+ but if you want to do that you could make your own Navigation Wrapper
struct MyNavigation<Content>: View where Content: View {
#ViewBuilder var content: () -> Content
var body: some View {
if #available(iOS 16, *) {
NavigationStack(root: content)
} else {
NavigationView(content: content)
}
}
}
and then just use it, like you would NavigationStack or NavigationView and on iOS 15 or older it would use NavigationView and on iOS 16 or newer it would use NavigationStack
Your code isn't accepted by Xcode because it isn't valid. You cannot have a { without a } in the same block.
I have found that using NavigationView can present problems on both iPhone and iPad apps running under iOS 16, even though NavigationView is only deprecated for now. On an iPhone, views reached from a NavigationLink often close themselves as soon as they are opened. On an iPad, the same problem occurs and the generation of Back arrows appears to be a bit random, especially in document apps. I have found it well worth making the effort to use NavigationSplitView and NavigationStack, even though this has involved me writing quite a lot of extra code to achieve pleasing results, particularly in apps designed to run at their best on both iPhone and iPad. That said, Apple do provide some clear advice on how to adopt the new Views here.
I have come across another oddity with iOS 16. Pickers in modal sheets, which have their list arrays populated .onAppear, no longer work as intended and the Picker selection can no longer be set programmatically. You have to populate the Picker's list before activating the modal sheet and pass it to the Sheet as a Binding.
Thanks halo for a top tip on how to use if #available().
I can't seem to change the tint color for selected UITabBarItem in iOS 10. It was working perfectly in iOS 9. I'm using Swift 2.x and have tried using self.tabBar.tintColor programmatically, and runtime attributes in storyboard as well.
Use like this;
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState:.Selected)
Thanks
I choose 4.7-inch as the default layout in Storyboard to make prototype more easily. 4.7-inch is iPhone 6 according to this link on Apple website.
In Xcode Preview, it's ok to show the layout.
But in iPhone 6 simulator, the layout is inconsistent to Preview.
Is it a bug in Xcode's Preview? Thanks.
FYI, Auto Layout and Size Classes are enabled, but I haven't add any constraint yet.
If constraints are enabled in your storyboard, then add constraints to it to be sure your layout behaves as you expect !
My setting for the project:
Deployment target: iOS6.1
Base SDK: 7.0
IB Document: Opens in 5.0
When I run app in simulator(7.0) I see almost what I expect (I don't understand why barbuttons don't use color tint — on previous screen it shows blue):
But if app is running on a device (also 7.0),
Then I see:
As you can see this is some kind of iOS6 UI, but tableview goes under the navbar, which became transparent.
Why does it happen?
Behavior of tintColor for bars has changed on iOS 7.0, please check the image below:
So now to change the tint color for your bar buttons you need to use tintColor which is the color for the interactive elements within a navigation bar including button images and titles.
While barTintColor is the background color of the UINavigationBar.
So basically
For buttons and title:
[[UINavigationBar appearance] setTintColor:[UIColor grayColor]];
For bar tint:
[[UINavigationBar appearance] setBarTintColor:[UIColor lightGrayColor]];
For the tableVIew under the navBar part, set navigationBar.translucent = NO;
I enabled Autolayout in IB, and now it uses iOS7 on a device too.
Upd.: After some time it start show strange design again. It gone only after I set iOS7 as base and deployment SDK.
so, i have an ios app and i have built it with interface builder and xcode. I built it using interface builder in the horizontal view because that is how i want my app. I have also made the supported views landscape left and right and i have edited info.plist to make it open horizontally.
But when i build and go it opens in iphone simulator horizontally but it shows as it would if it was vertical.
here's some screenshots:
what i want it to look like:
http://www.sendspace.com/file/4ct4b0
what it actually looks like:
http://www.sendspace.com/file/fayjqj
how could i get it to open like i want??
You have to allow the orientation also in your implementation of UIViewController using shouldAutorotateToInterfaceOrientation :
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return YES; //or UIInterfaceOrientationIsLandscape(interfaceOrientation) for just landscape
}
Also, if you have some more problems look on linked SO questions to this "out-dated" question:
iPhone app in landscape mode, 2008 systems