IOS Swift what am I messing up on in my UIView adding a subview -
i have uiview , set constraints on image below shows . when open in simulator works correctly . problem comes when try , add wkwebview display video , add subview . want video take dimensions of uiview video looks small , uiview looks shrinks . how can fix video takes full dimensions of uiview . can see constraints set trail , leading , video not taking width though large enough . thing can think of fixing adding a
addchildviewcontroller(viewcontroller)
however wkwebview not have controller suggestions great .
class exampletable: uiviewcontroller, wkuidelegate { @iboutlet weak var newview: uiview! var mywkwebview: wkwebview? override func viewdidload() { super.viewdidload() mywkwebview?.uidelegate = self guard let movieurl = url(string: "my video url") else { return } let webconfiguration = wkwebviewconfiguration() webconfiguration.allowsinlinemediaplayback = true webconfiguration.mediatypesrequiringuseractionforplayback = .audio mywkwebview = wkwebview(frame: newview.frame,configuration: webconfiguration) newview.addsubview(mywkwebview!) dispatchqueue.main.async (execute: { () -> void in self.mywkwebview?.loadhtmlstring("<video height=\"\(self.newview.frame.height)\" width=\"\(self.newview.frame.width)\" muted=\"muted\" autoplay=\"autoplay\" src=\"\(movieurl)\" playsinline/>", baseurl: nil) }) } }
my constraints
how looks no addsubview
can please check below code :
mywkwebview = wkwebview(frame: cgrect(origin: cgpoint(x:0,y:0), size: newview.frame.size),configuration: webconfiguration)
Comments
Post a Comment