Hi all,
I'm testing the B4i version of my cross-platform app using B4XPages (by @Erel).
The B4X code below runs perfectly in the Android (B4A) version of the app without errors but in the iOS version it crashes with this error: "Object was not initialized (UIImage)".
B4i DEBUGGING
I did 2 checks:
1) Checked through the log that the relative images are correctly initialized before calling the sub "CreateItem"(see log)
2) Check that the image is initialized ("If aImg.IsInitialized Then") before calling the .SetBitmap () function.
Both checks indicate that the ui image (object) in question, is always initialized.
I'm trying to understand why the app crashes with this error. Some idea?
LOG
Image ID = 229 | img.IsInitialized = true
Image ID = 121 | img.IsInitialized = true
Image ID = 122 | img.IsInitialized = true
Thanks in advance for your suggestions (useful also for other developers)
Luca.
I'm testing the B4i version of my cross-platform app using B4XPages (by @Erel).
The B4X code below runs perfectly in the Android (B4A) version of the app without errors but in the iOS version it crashes with this error: "Object was not initialized (UIImage)".
B4i DEBUGGING
I did 2 checks:
1) Checked through the log that the relative images are correctly initialized before calling the sub "CreateItem"(see log)
2) Check that the image is initialized ("If aImg.IsInitialized Then") before calling the .SetBitmap () function.
Both checks indicate that the ui image (object) in question, is always initialized.
I'm trying to understand why the app crashes with this error. Some idea?
B4X:
Public Sub LoadArtList (ArtContent As B4XOrderedMap)
'ARTICLE LIST CREATION (news listview)
clvNews.Clear
Private lstArt As List = ArtContent.Values
lstArt.SortType("CDate", False)
For i=0 To lstArt.Size-1
Private AI As ArtItem
AI = lstArt.Get(i)
'Private mapArt As Map = ArtContent.Get(ArtNID)
Private ArtVal As ArtValue
ArtVal.Initialize
ArtVal.ArtNID = AI.ArtNID
ArtVal.ArtTitle = AI.ArtTitle
ArtVal.ArtBody = AI.ArtBody
ArtVal.ArtImgID = AI.ArtImgID
ArtVal.ArtImgTitle = AI.ArtImgTitle
ArtVal.ArtImgAlt = AI.ArtImgAlt
ArtVal.ArtImgURL = AI.ArtImgURL
ArtVal.ArtImg = AI.ArtImg
Private imgID As Int = ArtVal.ArtImgID
Private img As Bitmap = ArtVal.ArtImg
Log ("Image ID = " & imgID & " | img.IsInitialized = " & img.IsInitialized)
ArtVal.CDate = AI.CDate 'creation date
Private pnl As B4XView = CreateItem (ArtVal)
clvNews.Add (pnl, ArtVal)
Next
clvNews.sv.ScrollViewOffsetY = 0
End Sub
Private Sub CreateItem (av As ArtValue) As B4XView
Private pnl As B4XView = xui.CreatePanel("")
pnl.SetLayoutAnimated (0,0,0,100%x, 100%y)
pnl.LoadLayout("article_itemlayout")
lblArtTitle.Text = av.ArtTitle
vwArtBody.LoadHtml(av.ArtBody)
Private aImg As Bitmap = av.ArtImg
'Private imgHeight As Int = 100%y-(lblArtTitle.Height + vwArtBody.Height)
If aImg.IsInitialized Then
'av is a type that contains all item data
'imgArticle, lblArtTitle are B4XView
'aImg is a Bitmap
'vwArtBody is a WebView
'>>> this is the line of code where the error occurs (only this line of code crashes the app, all the rest of the code runs fine):
imgArticle.SetBitmap(aImg.Resize(pnl.Width, pnl.Height-(lblArtTitle.Height + vwArtBody.Height), False))
lblImgAlt.Enabled = True
lblImgAlt.Text = av.ArtImgAlt
lblImgAlt.Visible = True
End If
Return pnl
End Sub
LOG
Image ID = 229 | img.IsInitialized = true
Image ID = 121 | img.IsInitialized = true
Image ID = 122 | img.IsInitialized = true
Thanks in advance for your suggestions (useful also for other developers)
Luca.
Last edited: