iOS OpenTok - How to style the video views? - ios

I am using the OpenTok iOS Framework to allow video chat within my app.
However, I am trying to find a way to custom style the views that display the user and connected user's streams.
From what I have found, it seems like these views are created in OTVideoView files, but I can only access the header.
Can anyone point me in the right direction on how to customize the views for the streams so I can make it look nicer than the default styling?

Hi, Each Subscriber.view of publisher.view is really a UIView object (Technical talk: OTVideoView is subclass of UIView). You can style them however you like by applying transforms and such to the view.
For example, to adjust width/height dynamically, you can do something like this:
[_publisher.view setFrame:CGRectMake(left, top, width, height)];
Anything you can do to UIView, you can do with OTVideoView.
Here's UIView's documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html
Hope that helps,
Song
P.S. If you have time, check out this blog post about using Core Graphics with OpenTok's video streams to do some nifty image recognition!
http://www.tokbox.com/blog/fun-with-core-graphics-in-ios/

Related

Is it possible to only screenshare a specific UIView using AppScreenSource?

Is it possible to only screenshare a specific UIView using AppScreenSource?
I'm creating an iOS app which is using RealityKit to place virtual objects on screen. I'd like to share this video with the other connected user in the room. AppScreensource seems like an almost perfect solution, but I don't want to share the entire screen - just my ARView. Is there a way to do this? Or do I need to go another route?
After going through the doc. I don't find any solution for capturing a portion of the screen. AppScreensource will the whole screen.
Link to the docs - https://www.twilio.com/docs/video/ios-v4-screen-capture
maybe you can use ARView's instance method snapshot(saveToHDR:completion:). There is a working example mentioned in this blog.

How to make Apple Watch center aligned UI as given in Apple Videos

I am trying to implement a UI in apple watch similar to what Apple shows in their videos.
I would like to show this in the GlanceInterfaceController as well as Apple Watch app's regular Interface Controller. I tried to group the label(WKInterfaceLabel) and image(WKInterfaceImage) objects using the WKInterfaceGroup object, however the view is not coming as both center aligned. Could you please give me some tips on how to implement it using Storyboard (interface builder). Also in the Interface builder, it is not allowing me to place a label(WKInterfaceLabel) on top of the image(WKInterfaceImage) object.
Expected UI (almost):
Developed UI (using Interface builder and Storyboard):
Is it due to some mistake in my Layout implementation?
Thank you in advance!
You can do that in several ways.
One of the easiest and fastest way is to put your elements inside a group and use the image for the group background.
Another way you can do that is generating an image with the text inside using something like this example from Apple.

How to make Custom GIF Keyboard in ios

I have one doubt that how exactly GIF images loaded into Custom keyboard and user can send it. I am new in iOS so want some link which i can refer and will be helpful for me.
Read Apple docs for this, especially this one https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html is a good strating point
You can set any UIView as the view for the keyboard layout, so an UIImageView is suitable for your purpose. The real difficulty in custom keyboarding is the management of events. As you are new to iOS dev, I would like to encourage you to try much simpler things first.

Make a Page Control like the iOS 7 Camera app

I was curious as to how you would make the custom page control that Apple has implemented in their camera app, with the text essentially acting as the page control and moving along with the swipe.
Are they using a UI Element that has the text fade into the background like that?
If you mean the text on the bottom ("Video", "Photo", "Square", ...) there's no stock component for doing it.
If I had to implement it I'd try with a UICollectionView with a flow Layout. You can easily play with alphas and 3D transforms to achieve the same effect.
As a reference you may want to look at the WWDC 2012 talks about UICollectionView, in one of which (can't remember which one) they explain how to build a cover flow interface with using a flow layout.

iPhone OS 3.2; PDF rendering; User Interaction

I'd need to create a iPad-app which would be rendering multiple PDF-Files (one file contains one page).
Each page should be scrollable, zoomable and if the user taps on a part of the PDF a website or photo gallery should popup.
Currently i think i could do that either with:
A. UIWebView
Displays the pdf's nicely, scrolling and zooming works. But it looks like a lot of trouble to realize the clickable parts of the PDF.
I don't know if i could use CGPDFContextSetURLForRect
Getting the touch-events from UIWebView to do something like CGPDFContextSetURLForRect my self looks like it would be some "quite bad" hack. See: http://github.com/psychs/iphone-samples/blob/master/WebViewTappingHack/Classes/PSWebView.m
B. Quartz
I found some resources describing how to display PDF's directly via Quartz.
See:http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html
This would allow using CGPDFContextSetURLForRect
But i have no idea if this would - like UIWebView - support scrolling and zooming out of the box?
Anybody could enlighten me on this please?
Thanks for your time!
[Edit: changed 3.0 to 3.2]
[Edit: my "solution"]
Hi!
I could come up with a working implementation for PNG but not for PDF's.
[Abstract]
My sollution was Rendering the content, intercepting the touches on it, retreiving the coordinates relative to the displayed content if it is one touch and finally looking up what to do from a mapping containing the interactive areas as coordinates and what to do if they get clicked.
[For PNG]
It was way more cumbersome to implement somethink like that than i would have imagined...
And the implementation i got working depends heavily on the content you want to display because this does work for UIImageView but i could not get it working with UIWebView.
First you need a UIScrollView and UIImageView to render the content and support scrolling/zooming.
Then you need to implement some handling to get the touches/gestures you are interested in.
See: developer.apple.com/iphone/library/samplecode/ScrollViewSuite/Listings/1_TapToZoom_Classes_TapDetectingImageView_h.html
This sample from apple provides everything you need to get this part working.
As a bonus it also takes care about transforming the coordinates relative to the viewport of the content which is very handy! (else you would only know where the tap happend on the screen wich only one half of the info you need if your content is zoom-/scrollable)
[For PDF]
If you want to do this with PDF the first thing would be that you need to use a UIWebView (probably you could do it via Quartz or something else too)
Getting the touches with a UIWebView is a real pain!
There are a lot of ways proposed on the web and besides one noone did what it should do.
After days of googling i found this gem: cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html
So... subclassing UIWebView does not get you anywhere unlike UIImageView and you have to subclass UIApplicationMain and implement its method for handling touch-events.
Here you could reuse some of the "Touch-Handling-Stuff" from the apple-examlpe from above.
Now you would need to translate the coordinates of the touch to your content if it is zoom-/scrollable. UIWebView DOES NOT do this for you unlike UIImageView!
I could never figure out how to get the required information(what part of the content at which zoomlevel) from a UIWebView to translate the coordinates but due to the changed requirements from PDF to PNG i didn't care to get it working too much.
hope this helps.
Using the CGPDF* operators will allow you to write a UIPDFView, which operates exactly as UIImageView but uses a PDF as the source image. Create your own custom subclass of UIView and implement drawRect: to, eventually, call CGContextDrawPDFPage. Based on a quick Google search (because I know the keywords), this page seems to explain that side of things quite well.
You can then directly substitute your custom UIView subclass for the UIImageView and proceed exactly as you have with the PNG solution.

Resources