I’ve been trying to get a popover to work but obviously don’t know what I’m doing when it comes to declares. Any help would be appreciated.
I created a method CreatePopover(inView As Ptr, popView As Ptr) that I call from a button action event:
[code] Dim vSelect As New SelectView
CreatePopover(Self.Handle, vSelect.Handle)
[/code]
The CreatePopover has the following code. (Note that this isn’t intended to be the final code, I’m just trying to get it to work.)
[code] Declare Function NSClassFromString Lib “Foundation” (classname As CFStringRef) As Ptr
Declare Function alloc Lib “Foundation” selector “alloc” (classRef As Ptr) As Ptr
Dim vPtr_SelectClass As Ptr = NSClassFromString(“UIPopoverController”)
Dim vPtr_Select As Ptr = alloc(vPtr_SelectClass)
// Init code
Declare Sub InitSelect Lib “UIKit” selector “initWithContentViewController:” (id As Ptr, viewController As Ptr)
InitSelect(vPtr_Select, popView)
Declare Sub DisplaySelect Lib “UIKit” selector “presentPopoverFromRect:inView:permittedArrowDirections:animated:” (displayRect As CGRect, inView As Ptr, arrowDir As UIPopoverArrowDirection, animated As Boolean)
Dim frame As CGRect
Dim frameOrigin As CGPoint
Dim frameSize As CGSize
frameOrigin.x = 0
frameOrigin.y = 0
frameSize.height = 200
frameSize.width = 100
frame.origin = frameOrigin
frame.mysize = frameSize
DisplaySelect(frame, inView, UIPopoverArrowDirection.UIPopoverArrowDirectionAny, True)
[/code]
When I run this and tap the button the code runs but nothing happens. If I change the x and y in the frameOrigin to anything other than 0,0 the application crashes.
Am I going about this in the right way, am I even close? Or do I need to be creating a class that I drag onto my view? If this is the case then can you please suggest an example I can study to learn how this is done. I have been looking at examples that use declares but have not gotten it right and don’t know what the correct way is.
Thanks.