Skip to content
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

Screen flash #7

Closed
llKoull opened this issue Aug 27, 2019 · 8 comments
Closed

Screen flash #7

llKoull opened this issue Aug 27, 2019 · 8 comments

Comments

@llKoull
Copy link

llKoull commented Aug 27, 2019

Hello!

First of all i want to thank you for this library ^_^

I've been using it for one of my projects and i saw that the screen flashes when i rotate the device and the semiModalView is open (i locked the app to be used in portrait mode only).

Any idea of how to avoid this flash?

Thanks and best regards!

@muyexi
Copy link
Owner

muyexi commented Aug 29, 2019

@llKoull Well spotted, just fixed, have a try with 1.0.1.

@muyexi muyexi closed this as completed Aug 29, 2019
@llKoull
Copy link
Author

llKoull commented Aug 29, 2019

Thanks for your suppor @muyexi but now the app crashes when i try to show the semimodalview using a real device (if i try to show it using the simulator, It works perfect). Tested using an iPhone 6, 7 and X.

Regards!

@muyexi
Copy link
Owner

muyexi commented Aug 29, 2019

@llKoull I tested the demo project on iPhone 6s, no crash, maybe something wrong with your integration?

@llKoull
Copy link
Author

llKoull commented Aug 30, 2019

It's so weird because sometimes when i try with the simulator, the view on the background disappears:

Simulator Screen Shot - iPhone 7 - 2019-08-30 at 07 03 56

But it never crashes, but it always crash using real devices for me.

It never happen using the old version and i think that nothing should be changed in the new one to show the semimodalview. I use this method to invoke the view:

`private final func showVehicleInformationView(_ vehicle: VehicleModel)
{
let options: [SemiModalOption : Any] = [
SemiModalOption.parentAlpha: 0.7,
SemiModalOption.shadowOpacity: 0.1,
SemiModalOption.pushParentBack: false,
SemiModalOption.animationDuration: 0.3
]

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier: "vehicle_information") as! VehicleModalInformationViewController
    
    viewController.delegate = self
    viewController.setVehicleImage(#imageLiteral(resourceName: "joyor_scooter"))
    viewController.setSerialNumber(vehicle.getSerialNumber())
    viewController.setBrandAndModel(vehicle.getBrandAndModel())
    viewController.setBatteryImage(vehicle.getBatteryLevelImage())
    viewController.setBasePrice(vehicle.getBasePriceWithCurrency())
    viewController.setFarePrice(vehicle.getFarePriceWithTimeAndCurrency())
    
    viewController.view.frame.size = CGSize(width: self.view.frame.width, height: 468)
    
    self.presentSemiViewController(viewController, options: options)
}`

Regards! ^_^

@llKoull
Copy link
Author

llKoull commented Aug 30, 2019

I've been doing some tests and and now, my flow is:
1 - I have a map with POI's.
2 - The user touches a POI and then i center the map using the POI coordinates plus an offset.
3 - I show the semimodalview with the information.

It was working using the old version, but now it crashes. I can avoid the crash if i remove the step 2, but only in the new version but then i get a crash in another line of the code (the first crash it's like an internal crash related with the animation of the model view and metal :S):

Captura de pantalla 2019-08-30 a las 8 13 56

Regards!

@muyexi
Copy link
Owner

muyexi commented Aug 30, 2019

@llKoull Since I can't reproduce the crash on my side, could you fix it and make a pull request?

@llKoull
Copy link
Author

llKoull commented Aug 30, 2019

Yeah, i'm going to do some tests and i'll keep you informed ;)

@llKoull
Copy link
Author

llKoull commented Aug 30, 2019

Hi @muyexi I think that i found the problem (but no the solution) you use a method called asImage() that takes a "screenshot" from the current view and the problem is that if the view is running any animation, the method crashes.

As i commented, the main view is a MapView and i do an animation to center the map using the coordinates of a POI and, if i cancel the animation, the semimodalview works great.

I finally added an small delay and it seems to work perfect:

`func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool)
{

    if let selectedAnnotation = self.selecctedAnnotation as? VehiclePointAnnotation, let vehicle = selectedAnnotation.getVehicle() {
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
            self.showVehicleInformationView(vehicle)
        })
    }
}`

Thanks and best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants