Interesting change in Modal View Behavior

I use the exact same code to close modal views. And I can show ModalView1 and ModalView2 without any problem.

Maybe the problem comes from the way you create a modal view? What’s the code for that?

Dim v As new ModalView1
self.PushToShowModalXC(v, ViewExtensionsXC.UIModalPresentationStyle.formSheet)

PushToShowModalXC is from your iOSDesignExtensions:

Declare Function NSClassFromString Lib "Foundation" (className As CFStringRef) As Ptr
Declare Function alloc Lib "Foundation.framework" selector "alloc" (clsRef As ptr) As ptr
Declare Function initWithRootViewController_ Lib "Foundation" selector "initWithRootViewController:" (obj_id As ptr, rootViewController As ptr) As ptr
Declare Sub presentViewController Lib "UIKit.framework" _
Selector "presentViewController:animated:completion:" _
(parentView As Ptr, viewControllerToPresent As Ptr, animated As Boolean, completion As Ptr)
Declare Sub modalPresentationStyle_ Lib "UIKit.framework" selector "setModalPresentationStyle:" (obj_id As ptr, modalPresentationStyle As UIModalPresentationStyle)



Dim navController As ptr = initWithRootViewController_( alloc(NSClassFromString("UINavigationController")), v.ViewControllerHandle ) 


modalPresentationStyle_(navController, style)



If callback <> Nil Then
  Break
  //This code might fail
end if

If callback Is Nil Then
  presentViewController(parent.Handle, navController, Animate, Nil)
Else
  presentViewController(parent.Handle, navController, Animate, callback.handle)
End If

I am using the exact same code without issues…

Maybe create a sample project with just the three views to replicate the issue?

Yes, I think I’ll have to do that. I will keep you posted.

1 Like

Hmm, when I set a breakpoint, it stops at
Dim v As new ModalView2
and the code will just not proceed. I push Cmd+Shift+O or Cmd+Shift+I, nothing happens. It’s stuck in that line.

Created a test project with the exact same code and it works. So there’s got to be something else in my app. Somewhere. Super frustrating, sometimes I just wanna give up on iOS.

Does the app crash or is there an exception raised?
This is strange behavior.