iOS Question Scrollview not starting at offsetpositiony = 0

tufanv

Expert
Licensed User
Longtime User
Hello,

If the scrollview's content height is more than the height of the scrollview, my scrollview always starts a little scrolled down from the top. Even if i manually execute scrolloffsety=0 it doesnt work. As it is a huge project I couldn't post a demo but anyone else experienced this ?

TY
 

tufanv

Expert
Licensed User
Longtime User
I am still messing with this problem. After long tests I find that if the interstitial ad is shown, the scroll offset y of the scrollview changes like this ( I have put log under scrollview scrollchanged)
ofset:6
ofset:-3
ofset:9
ofset:2

And when i close the interstitial :
ofset:8

If I never show the interstitial, there is no problem with the scrollview, scrollchanged is never triggered. can you please check this ?
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
The last scroll is caused just after the interstitial is closed so if we had an iad_closed we could use scrollview1.scrollto(0,0) maybe but there is no event like that. It is an interesting problem which messes with my scrollview.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can try to do something like:
B4X:
iad.Show(Page1)
 Sleep(100)
ScrollView1.ScrollTo(0, 0)
Though it doesn't look correct to scroll the ScrollView. What if the user has scrolled it?

Anyway, this is something that happens in the underlying native layout engine. Obviously the ScrollView wrapper will never scroll the ScrollView unintentionally.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
You can try to do something like:
B4X:
iad.Show(Page1)
 Sleep(100)
ScrollView1.ScrollTo(0, 0)
Though it doesn't look correct to scroll the ScrollView. What if the user has scrolled it?

Anyway, this is something that happens in the underlying native layout engine. Obviously the ScrollView wrapper will never scroll the ScrollView unintentionally.
I dld try that but that did not work because the last scroll happens whwn you close the ad. If we had ad_closed event, I could do that.I am sure that user is not scrolling i can reproduce this behaviour while debugging without touching anything. I can post a video here or something.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can add a "closed" event with this inline code:
B4X:
Sub iAd_Closed
   Log("closed")
End Sub

#if OBJC
@end
@interface B4IAdInterstitial (event)
@end
@implementation B4IAdInterstitial (event)
- (void)interstitialDidDismissScreen:(GADInterstitial*)ad {
   [B4IObjectWrapper raiseUIEvent:self :@"_closed" :nil];
}
#End If
 
Upvote 0
Top