iOS Question Why UIFont Initialization Error in B4I here?

ZainAlAazizi

New Member
Hi. I have made a test app and defined a font in it.
I drew a circle with a "Hello World!" text.
It works fine in B4J and B4A.
In B4i, the error message below was shown:

Application_Start
*** mainpage: B4XPage_Created
Error occurred on line: 41 (B4XMainPage)
Object was not initialized (UIFont)

I tried many things to fix it but I failed.
I am a beginner. Could you help me?
Attached is the essential parts of the project.
I have deleted some files because the post refused to upload the whole project
 

Attachments

Last edited:
[CODE lang="b4x" title="B4XMainPage" highlight="34"]Sub Class_Globals
Private Root As B4XView
#If B4J
Private fx As JFX
#End If
Private xui As XUI
Private pnlDraw As B4XView
Private layer As B4XCanvas
Private fontObject As B4XFont
End Sub

Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
fontObject=CreateB4XFont("calibri.ttf",50,12)
layer.Initialize(pnlDraw)
layer.DrawCircle(pnlDraw.Width/2,pnlDraw.Height/2,pnlDraw.Width/2,xui.Color_DarkGray,False,5)
layer.DrawText("Hello World!",pnlDraw.Width/2,pnlDraw.Height/2,fontObject,xui.Color_Red,"CENTER")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub CreateB4XFont(FontFileName As String, fontSize As Float, NativeFontSize As Float) As B4XFont
#If B4A
Dim TT As Typeface = Typeface.LoadFromAssets(FontFileName)
Dim fontObj As B4XFont = xui.CreateFont(TT, fontSize)
#Else If B4i
Dim TT As Font = Font.CreateNew2(FontFileName, NativeFontSize)
Dim fontObj As B4XFont = xui.CreateFont(TT, fontSize)
#Else ' B4J
Dim fontObj As B4XFont = xui.CreateFont(fx.LoadFont(File.DirAssets, FontFileName, NativeFontSize), fontSize)
#End If
Return fontObj
End Sub[/CODE]
 
Upvote 0
Back
Top