ios - MPMoviePlayerController not staying within bounds of UIView -


i trying add video uiview container within modal window. when add video not stay within bounds of uiview bounded to. here picture of looks like:

current state

the grey container can see right edge of container , here view controller adds video.

import foundation import mediaplayer  class evalinstructionsvc: uiviewcontroller {     private var movieplayer : mpmovieplayercontroller?      @iboutlet weak var video: uiview!      func playvideo() {         let path = nsbundle.mainbundle().pathforresource("time rotate demo", oftype:"mp4")         let url = nsurl.fileurlwithpath(path!)         movieplayer = mpmovieplayercontroller(contenturl: url)         if let player = movieplayer {             player.view.frame = video.bounds             player.view.center = cgpointmake(cgrectgetmidx(video.bounds), cgrectgetmidy(video.bounds))             player.preparetoplay()             player.scalingmode = mpmoviescalingmode.aspectfill             video.addsubview(player.view)         }     }      override func viewdidload() {         super.viewdidload()         playvideo()     }      @ibaction func done(sender: uibarbuttonitem) {         self.dismissviewcontrolleranimated(true, completion: nil)     } } 

as can see bounds being set , being added sub view video uiview grey box in screenshot above.

i appreciate can provide.

cheers, gerry

call player.view.frame = video.bounds later in view controller lifecycle.

simplest solution call playvideo() viewdidappear:

override func viewdidappear(animated: bool) {     playvideo() } 

fyi, our code similar (based on same example?), think won't need set player.view.center.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -