0

I'm making an iOS app using xcode 6 and swift. I'm using TokBox for live videochat. So far it is working fine. My only issue is the position of the camera view. I have tried to put the view inside a view container, but that doesn't seem to solve my issues. Right now i have hardcoded the position of the camera to fit an iPhone 4. Is there a way to put it inside a container and then use autolayout afterwards?

func PublishToSession()
{
    Publisher = OTPublisher(delegate: self)

    var Error : OTError?

    Session?.publish(Publisher, error: &Error)

    if let error = Error
    {
    //Some message
    }

    view.addSubview(Publisher!.view)

    Publisher!.view.frame = CGRect(x: 0, y: PubVideoHeight, width: PubVideoWidth, height: PubVideoHeight)
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Loc Dai Le
  • 1,661
  • 4
  • 35
  • 70

1 Answers1

0

You should be able to place the publisher's view inside your own custom view. Your custom view code would then have to handle all the AutoLayout concerns and dynamically resize the inner view on its own.

This tutorial (which is unrelated to OpenTok but shows how to write a custom view which supports AutoLayout) may be helpful: https://tech.coursera.org/blog/2014/10/29/writing-a-custom-control-ios-8/.

Ankur
  • 2,792
  • 3
  • 23
  • 26
  • Thank you for your response @Ankur - but why can't i just drag n drop a UIVIEW into my storyboard and use that? - do i need to make a custom one? – Loc Dai Le Aug 10 '15 at 18:54
  • the default renderer does not currently implement the newer UIView API which enables the AutoLayout features. In general, the default views are meant to be light weight. I understand that you are hoping for a more "out of the box" experience, and I'll capture that feedback for the team. – Ankur Aug 13 '15 at 02:58
  • @LocDaiLe the reason is because the default OTVideoRender instance (https://tokbox.com/developer/sdks/ios/reference/Protocols/OTVideoRender.html), which is the subclass of UIView that is instantiated by the OTSubscriber and OTPublisher, does not implement the Auto Layout methods. Another option would be to use the OTPublisherKit and OTSubscriberKit (a lower layer of the API) and provide your own OTVideoRender instance which does handle Auto Layout. I've noted your feedback internally. – Ankur Aug 20 '15 at 18:26
  • @Ankur Is there an official Swift SDK for video calls? – rocket101 Aug 26 '15 at 11:37
  • @rocket101, there is not, but the ObjC based SDK works just as well from Swift in my experience :) – Ankur Sep 08 '15 at 01:08