-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Status bar color and image orientation issues #452
Comments
Hello @Shouheng88, thanks for the raise out of the issues. As far as I know, this library is mainly developed using UIKit, so suppose you will need UIViewRepresentable to bridge to SwiftUI. For Image orientation, would you please provide some reference e.g. reproducable project that we can investigate? Thanks. As always, feel free to submit any pull requests if you are willing to do so! |
Hi @tommyming, thanks for your reply. I fixed the status bar color issue by chaning the background color. Now it works well. For the image orientation issue. As you can see in the below two images. The first one is the image diplayed by I used to meet this problem when I program with Android. In Android, we need to read the image orientation from the fun File.orientation(): Int {
try {
val exif = ExifInterface(absolutePath)
return when (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) {
6 -> 90
3 -> 180
8 -> 270
else -> 0
}
} catch (e: IOException) {
e.printStackTrace()
}
return 0
} I'd love to contribute code. But I'm new to iOS development. I'll try to find a solution. I hope the information will help! Thanks a lot! |
It's little strange, the image orientation works well if I use the UIImage instead of url string to get SKPhoto object. The image from network also works well. Here is my code in SwiftUI struct ImageBrowseView: View {
@Environment(\.presentationMode)
private var presentationMode: Binding<PresentationMode>
@State private var isClosing: Bool = false
private let photos: [SKPhoto]
private let initIndex: Int
@State private var index: Int = 0
let urls: [URL]
let url: URL
init(urls: [URL], url: URL) {
self.urls = urls
self.url = url
self.photos = urls.map { url in
if url.isFileURL {
SKPhoto.photoWithImage(UIImage(data: try! Data(contentsOf: url))!)
} else {
SKPhoto.photoWithImageURL(url.absoluteString)
}
}
var index = 0
for i in 0..<urls.count {
if urls[i] == url {
index = i
}
}
self.initIndex = index
self.index = index
}
var body: some View {
ZStack {
Color.background_color.ignoresSafeArea(.all)
PhotoViewer(photos: photos,
initIndex: initIndex,
index: $index,
isClosing: $isClosing)
}.onChange(of: isClosing, perform: { value in
if value {
presentationMode.wrappedValue.dismiss()
}
}).navigationBarHidden(true)
}
}
struct PhotoViewer: UIViewControllerRepresentable {
let photos: [SKPhoto]
let initIndex: Int
@Binding var index: Int
@Binding var isClosing: Bool
func makeUIViewController(context: Context) -> SKPhotoBrowser {
SKPhotoBrowserOptions.indicatorColor = R.color.image_tint_color()!
SKPhotoBrowserOptions.displayAction = false
SKPhotoBrowserOptions.displayCloseButton = false
SKPhotoBrowserOptions.displayHorizontalScrollIndicator = false
SKPhotoBrowserOptions.displayCounterLabel = false
SKPhotoBrowserOptions.displayBackAndForwardButton = false
SKPhotoBrowserOptions.backgroundColor = R.color.background_color()!
let browser = SKPhotoBrowser(photos: photos)
browser.initializePageIndex(initIndex)
browser.delegate = context.coordinator
return browser
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func updateUIViewController(_ browser: SKPhotoBrowser, context: Context) {
}
class Coordinator: NSObject, SKPhotoBrowserDelegate {
var control: PhotoViewer
init(_ control: PhotoViewer) {
self.control = control
}
func didShowPhotoAtIndex(_ browser: SKPhotoBrowser, index: Int) {
self.control.index = index
}
func willDismissAtPageIndex(_ index: Int) {
self.control.isClosing = true
}
}
} |
Thanks for the reply, I think it might be the problem of the convenience init methods, I will have a check and update you later. |
@Shouheng88 sorry for the late update, may I know if the orientation issue happens on the local image? |
Yes, only the local image from camera has this prolbem. |
@Shouheng88 Hello there, sorry for the long-awaited update. May I know which version of iOS you are using, and did you set any image orientation methods for the local image that has the issue? |
Thanks for your patience. I'll try the code later. For questions,
|
First of all, thanks for your work for this library.
When I tried to use this library in SwiftUI in my App, I found two issues:
When exit from the photo browser, the status bar didn't recover. The photo browser changed the status bar color to white, but when exit, it didn't change it back to black.
Image captured from camera is displayed and rotated with 90 degrees.
I think these fixing theses issues will make the library better. Thanks!
The text was updated successfully, but these errors were encountered: