I am engaged on a react native wrapper to a third social gathering library.
I must show a view that may show a picture that’s loaded through the third social gathering library.
So i first add a subclass of RCTView within the view hierarchy, begin loading the picture and when the picture is loaded I resize the view to show the picture with no cropping or padding.
The problem i am working into is that I can resize my subclass of RCTView and that works fantastic, however different component round my view aren’t relayed out, so my view find yourself behind the view that’s under it…
Right here is the screenshot, the white half within the center must be taller to show the complete picture.
The vital a part of the code
class EquativDisplayView: ExpoView {
let container = UIView()
var bannerView:SASBannerView?
required init(appContext: AppContext? = nil) {
tremendous.init(appContext: appContext)
clipsToBounds = true
addSubview(container)
}
override func layoutSubviews() {
//be sure that all of the view maintain the identical dimension
container.body = bounds
bannerView?.body = bounds
}
func setConfiguration(_ configuration: Configuration) {
//load the picture
let bannerView = SASBannerView(body: CGRect(x: 0, y: 0, width: bounds.width, top: 0))
let adPlacement = SASAdPlacement.init(testAd: SASAdPlacementTest(rawValue: testPlacementId) ?? .bannerMRAID)
bannerView.load(with: adPlacement)
bannerView.delegate = self
// Including the banner view to the present view controller
container.addSubview(bannerView)
self.bannerView = bannerView
}
}
extension EquativDisplayView :SASBannerViewDelegate
{
func bannerView(_ bannerView: SASBannerView, didDownloadAd advert: SASAd) {
print("advert did load")
let optimalHeight = bannerView.optimalAdViewHeight(forContainer: nil)
let newFrame = CGRect(x: body.origin.x,
y: body.origin.y,
width: body.dimension.width,
top: optimalHeight)
body = newFrame
print("resizing %@", newFrame)
setNeedsLayout()
superview!.setNeedsLayout() < ============ at this level I am anticipating the display format to get up to date, however i am clearly lacking one thing
}
}
the react native aspect
export default operate App() {
return (
<View type={kinds.container}>
<View type={{ top: 100 }} />
<Textual content type={{ flex: 1, backgroundColor: "yellow", width: "100%", textAlign: "middle" }}>
{EquativDisplay.hey()}
</Textual content>
<EquativDisplay.EquativDisplayView
type={{
width: "100%",
padding: 10,
backgroundColor: "inexperienced",
}}
configuration={{
testPlacementId: EquativDisplay.PlacementTest.BannerMRAID,
}}
/>
<Textual content type={{ flex: 1, backgroundColor: "yellow", width: "100%", textAlign: "middle" }}>
{EquativDisplay.hey()}
</Textual content>
</View>
)
}
The output from the logs:
layoutSubviews %@ (0.0, 0.0, 393.0, 20.0)
advert did load
resizing %@ (0.0, 466.0, 393.0, 61.0)
layoutSubviews %@ (0.0, 0.0, 393.0, 61.0)
The peak must be 61 which is right, the underside yellow view must be resized, however will not be.