I am reading Apple documentation regarding AVFoundation framework. I want a NSView in my Cocoa application to play video in my application. It's a tutorial video something similar to what apple provides in their application.
My question is, while reading this document...
AVFoundation programming guide
Most of the classes mentioned are related to iOS as an example...PlayerView extends from UIView.
Now, before I code I want to ask should if I am making application using same example code for Cocoa App should I read UIView as NSView? is that the solution?
I haven't tried as it's lots of code, I thought it's better to understand it before start coding.
In this specific example you should be ok replacing UIView with NSView with possibly some minor changes, since it seems like a lot of the work is being done on the view's layer, which is a property that exists in AppKit as well as UIKit for NSView and UIIView respectively.
I am not sure what you overall goal is here, but as long as you are not intending to copy the doc line for line, you'll be ok; ie you might need to make small changes.
Hope this helps.
It sounds like you want a simple QTMovieView loaded up with a video to play
Related
I'm trying to get to grips with using Chipmunk (not the Obj-C version) with UIKit components on iOS, and still struggling immensely.
I'm trying to establish how, in the ChipmunkColorMatch example in the documentation, the UIButton instances are actually hooked up to any of the physics calculations. I see that the UIButtons are created inside the Ball class, and some of their properties are set, (type, image, etc.), but I'm not understanding where the cpBody or cpShape or whichever it is is actually attached to that UIButton. I assume it needs to be, else none of the physics will be reflected in the UI.
I've looked in the SimpleObjectiveChipmunk tutorial on the website too, but due to the fact that it uses libraries unavailable to me (the Obj-C libraries), I can't establish how it works there, either. Again, I see a UIButton being created and positioned on-screen, but I don't see how the cpBody (or in that case, ChipmunkBody) is linked to the button in any way.
Could anyone shed some light on how this works? Effectively what I'm going to need are some UIButton instances which can be flicked around, but I've not even got as far as working out how to create forces yet, since I can't get the bodies hooked up to the buttons.
Much obliged, thanks in advance.
EDIT: Should also point out that I am not, and do not want to use cocos2d in this project at all. I've seen tutorials using that, but that's a third layer of confusion to add in. Thanks!
Assuming this source is the project you're asking about, it looks like the magic happens in Ball's sync method -- it creates a CGAffineTransform representing the translation and rotation determined by the physics engine, and applies that to the button.
In turn, that method is called by the view controller's draw: method, which is timed to occur on every frame using CADisplayLink, and updates the physics engine before telling each Ball to sync.
I'm trying to use that MGSplitViewController (already mentioned here, but some one told me I have to ask a new question...), because some ideas will have one or more splitviews and Apple's reviews are not that easy to pass, so I thought I just use some time to test some existing frameworks, like the MGSplitViewController.
But I don't get it working for about 4 long and hard days(and some nights, too ;) ) - any help would really be really great!!!
My problem is the following:
I have just a simple start view with a segmented control. after the launch and some checks I would like to load the splitview in that simple view. I'm using the storyboard for the simple view and I added the xibs from the example (because I had no idea how to integrate them in the storyboard as well - seems to be the next topic, I'll take a look at...)
Sounds very easy, but with the commented header file and the demo project I'm absolutely not able to reproduce it for a non root controller loading...
I have packed the source code for better understanding, downloadable at
http://www.file-upload.net/download-3866273/mgsplittest.zip.html
.
If any one can help me with this, correcting the project, this would be really, really, really great!!!
Greetings,
matthew
I have solved the issue -
FORGET MGSplitViewController :)
Write it your own, really not difficulty:
need two views(navigation_left_sided, detailsview_right_sided) in the YOURSPLITVIEWController in the storyboard
all detailviews should be build with xibs, in storyboard I have not found a way doing this in a clean way (any tipps appreciated)
the leftsided view delegates calls/view loadings to the other
load your detailview controller and display
finished ;)
It is also a good training to work with delegates, observer and asynchronous dispatching. At the time I asked the question, I have not worked much with them - blame on me ;)
Advantage of writting your own:
- reusable
- fully customizable
- in portrait mode also visible, you can just change the sizes of both
- custom animations for changing the detailsview (move details from bottom to top or curl or anything)
- after this you have a lot of basic knowledge like delegates, etc... (it was in my case)
Or use the iOS6 feature for grids also very simple, but iOS6 based devices only...
That's it, very easy :)
Any questions? Just ask :D
But I have written the code for my company, so I cannot share, just answering questions and giving you the tipps from above ;)
Greetings,
matthias
Let me get this out of the way: I'm used to to UIKit, where you can push/pop view controllers to your hearts content. That just doesn't work on the Mac.
With TwUI, this works extremely well on the Mac. For example, look at #joshaber's push/pop example using TwUI. If TwUI was completely stable and capable of embedding AppKit controls inside a TUIView, I would ditch AppKit completely. However, not everything can be done in TwUI, and I need to retain AppKit for some things.
Thus brings my question. How can something like this be accomplished using AppKit? Is there a library that has made this easy? Or do we need to make it ourselves? Just using replaceSubview:withSubview: isn't enough, and isn't really pushing/popping views.
You're asking about how to push/pop NSViews? I have another example on GitHub at https://github.com/joshaber/ReederDemo that does that. You can take the guts of PPNavigationController from TwUIPushPopTest and replace it with the stuff to do the animation in ReederDemo. It'd still be far from complete, but it'd at least get you pushing and popping view controllers with a kinda-right animation.
Ah, I think I found what I was looking for.
Behold PXNavigationBar:
Combining this and Josh's push/pop example I've come up with a good system. I'll leave Josh's example selected because that fixes the root problem.
Is there disadvantages to using WebKit WebViews compared to using NSViews?
I'm using a webview to create a UI for an application. The application itself does not have much interactivity. I have seen it mentioned, on this website & others, that using a WebView can be convient means of prototyping.
However, with our team this seems like an ideal way to produce the production ready UIs, especially with WebKit. Are we missing something?
Thanks,
Ross
Okay, so you seem to be asking if using an HTML interface (presented via a WebView) for your application has any disadvantages.
The answer to this is "no", at least "not necessarily". This is analogous to building an iPhone specific web application, and there are some excellent examples of those. The caveat would be that a lot of those sites end up recreating the look and feel of a native iPhone app, for consistency and to make the users feel "at home".
Given that you're developing a native app anyway, it seems a shame to throw away, or recreate, the responsiveness and appearance of the native chrome. Of course, for certain types of applications (games are an obvious example) a user has no expectations about the application's UI, so you're free to knock yourself out.
The other factor to consider is the amount of interactivity (although I notice that you say there isn't much in your case). The native controls will make coding a lot simpler than having to capture all user input through the "filter" of a WebView, even though using one might make the initial layout of the screens easier.
I hope that's the sort of answer you were looking for (although it's mostly non technical).
As you might have known if you spend some time in the documentation, you'd have seem that WebView is a subclass of NSView.
The documentation says about WebView:
WebView is the core view class in the WebKit framework that manages interactions between the WebFrame and WebFrameView classes. To embed web content in your application, you just create a WebView object, attach it to a window, and send a loadRequest: message to its main frame.
And about NSView:
NSView is a class that defines the basic drawing, event-handling, and printing architecture of an application. You typically don’t interact with the NSView API directly; rather, your custom view classes inherit from NSView and override many of its methods, which are invoked automatically by the Application Kit. If you’re not creating a custom view class, there are few methods you need to use.
So here's the answer to your question:
Is there disadvantages to using WebKit WebViews compared to using NSViews?
Yes. You can't display any web content with NSView. That's what you need WebView for.
I suggest reading some more documentation though.
I am a learner in the area of Objective-C. I'm trying to build an iPhone app with cocos2d. Now I would like to use a UITableView to show data from an XML file.
Is it possible to use UITableView with cocos2d and is it also possible to retrive data from an XML file?
You can very easily integrate UIViews with cocos2d scene by using CCUIViewWrapper class which was made by someone and posted on cocos2d forum. I had used it and it is pretty simple to use everything is there on the forum.
And for XML parsing it's better if you use the parser provided by iOS as Jonathan said cocos2d is a game engine which doesn't provide any mechanism to parse XML files.
Absolutely! The XML file doesn't even have to be local in your app.
I recommend parsing the XML with something like TouchXML. The only built in iPhone XML parsing library is a event based one that is hard to use unless you have the right sort of structure in you data.
Then in the table view methods that fill your table with data, select items from the variables that you have parsed out of the data file.
Yes, Squeegy is right. I do want to correct a conceptual misunderstanding you appear to have, though. Any iPhone application you write will always be based on the core iPhone APIs. Thus, your using Cocos2d is irrelevant to your use of UITableView. As for XML parsing, that is, of course, not done by Cocos2d. Cocos2d is a high-level abstraction of OpenGL for relatively easy game development; XML parsing is not in its purview. Thus, again, your use of Cocos2d is irrelevant to your use of an XML parsing library.
It is possible to use UITableView objects, UINavigationViewControllers etc alongside your Cocos2D app.
Just create a UIViewController in applicationDidFinishLaunching and add it's view to the window.
Hold onto the EAGLView* Cocos2D uses, and switch between this OpenGL view and your view controller (with it's table views, buttons, and what have you).
If you want to display a table simultaneously with your Cocos2d content, it might be best to use the UI elements they provide.
There is also the possibility of using cocos2d extensions. These are pretty much some UIKit classes rewritten in cocos2d.
Here is a link I found with scroll and table views.
There isn't much explanation on how to use it, but it doesn't differ too much from UIScrollView and UITableView.