iOS - QuickLook - How to open an object in QuickLook without a UIScrollView - iphone

Could anyone point me towards a resource which uses QuickLook to open a (preferably but not necessarily a pdf) file without using a UITableView?
I do have this example of using QuickLook but it uses a listview which I need to get away from.
http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html

I'm not sure how you plan to design your UI to open a file. I've used a few different ways, so I'll toss out some ideas. A UITableView is ideal for large amounts of files. A generic scroll view can also be used for a large number of files. I've used an alert view for an app that only generates one or two files. You could also use a view with document icons like the iPad Mail app. To get the document icons, use UIDocumentInteractionController. The WWDC 2010 DocInteraction sample code goes in great depth with how to use UIDocumentInteractionController.
As for opening the file, the Quick Look framework makes that easy. A simple, self-contained solution is to subclass QLPreviewController. Then, your subclass needs to conform to the QLPreviewControllerDataSource protocol and optionally the QLPreviewControllerDelegate protocol. Next, pass it an array of NSURLs pointing to your files. You can do this either through an initializer like -initWithFiles:(NSArray *)files or through a setter. From here, -previewController:previewItemAtIndex: just needs to index into the array to get the appropriate file to show. -numberOfPreviewItemsInPreviewController: just needs to return the size of the array. Once you have this class finished, you can use any UI design you like to push this view or present it modally.
Hopefully this is more clear than my tutorial you've been reading.
EDIT:
I have posted some code to Github that may help you. I have created a file previewer class as described above. I also posted a demo app that directly uses a QLPreviewController.

Related

Creating a List of Custom Views in Xcode

I'm currently working on developing a desktop application for MacOS for downloading batches of audio files from URLs at one time I've run into a question about UI design that I can't figure out.
I have a class called SongEntry.swift that holds information regarding the URL that was entered (e.g. url, title, length, author, etc.) and I want to create a vertically growing list of custom views that updates when a new one is added.
Where is what the base view looks like:
Inside of the big white area is where I want the list to be held.
I've tried to create a separate view controller that handles each entry but that didn't work. I know UI design for MacOS is much different from iOS, however I think what I'm looking for is a way to simulate the table views and cell prototypes from iOS but can't find a suitable option.
If anyone knows of a possible solution or can point me in the right direction, I'd greatly appreciate it!
What you want is one of the collection views. For vertical list, you'll probably use NSTableView with only one column and hide everything else like headers.
Here are roughly the steps you need:
You can use your existing view controller or create a dedicate view controller for just the table (and use the 'embed' option in Interface Builder)
This view controller will adopt the NSTableViewDataSource and NSTableViewDelegate protocols to provide the data (your SongEntry objects) and the view for each row.
You set your NSTableView's source and delegate to your view controller.
You create a view which will serve as your "cell", it will be used by each row to display the data. You can design it either in IB or in code.
The entire process is described in detail in the Table View Programming Guide for Mac.
This topic can be a bit confusing. Note that there are two main approaches: the view-based and NSCell-based tables. Don't bother with the NSCell way, it's more of a legacy leftovers.
Also note that there are some overlap of methods in both NSTableViewDataSource and NSTableViewDelegate to provide data and views that can be a bit confusing at first. Just play around with the code and samples and it will be clearer which delegate method to use when.
There are many examples both on Apple's developer site and github. Also a good tutorial on raywenderlich.com.

Swift 1.2 drag and drop controls and views in Cocoa

I'm building one application where I need to make a simple window and be able to drag&drop files onto this window. In this app I have to then parse file path and write out all paths of dropped files in table or nice order (one under another). App doesn't need to take more than one file at once, but this might be a feature for future.
Up to now I have managed to make simple drag&drop in NSView (which I extended with custom class). App is correctly registering drag&drop events and I get all file path and I have also figured how to get file names out of those strings.
My question is: How can I move this "drag&drop" to NSTableView, as I wish to have file names in nicely in table?
I have tried to put tableview under NSView but it doesn't work and if I extend NSTableView class it just registers that there was drag&drop event but nothing else happens.
Do I have to extend other class or how to make this work? I'm implementing NSDraggingDestination protocol in custom class and using performDragOperation function.
I would like to have:
- whole app window can take drag&drop-ed files, not matter where I drop it it has to accept file and put file name into table
I'm sorry if this might sound trivial but I have just started learning swift and developing OS X apps and I'm not used to this new API and don't really know how all things works here.

Swift and Parse - PFQueryTableViewController loadingViewEnabled

Good day! I'm using Parse for my swift project, Specifically the PFQueryTableViewController but i want to change the loading view when i open the app. It doesn't look good in my background so i want to change its color and shadow. Also its UIActivityIndicatorView. Is it possible to change this things? Here is the Screenshot for it.
I tried searching for that method in ParseUI framework but i can't find it. I hope you can help me, Thanks!
Only the table controller is unique to Parse. The spinner is just a regular UI element. Thus, the iOS developer references are good places to look for this.
Try this link for the activity spinner:
This link shows information about the controller, which shows that it simply inherits from UITableViewController, and the cells/background can be styled accordingly.
In general, Parse tries to prefix its objects with PF.

UIPageViewController/TextKit Multipage flow in SWIFT

Has anyone had any luck creating a multiple page view of document (one, NSTextStorage, one NSLayoutManager, and multiple NSTextContainers) in Swift. I'm having a lot of trouble finding example code not in objective C.
Basically, I'm trying to recreate the "Advanced Text Layouts and Effects with Text Kit" demo from WWDC 2013, but the whole thing is in Objective C and there is no sample code to be found. The post below seems to be having luck; but I'm having no luck translating...
UIPageViewController/TextKit Reflowing Text on paging
http://rshankar.com/quotes-app-simple-page-based-application-in-swift/
This uses the Page Based Application project template for a out-of-the-box working example, then customize for the model you want to use.
It use this same technique in my app by changing the root controller to what ever viewController I want it to be, coping the three files into my app, and all the magic is done for me.

Iphone sdk - How to setup a 'template'

I've been working on a Cook Book App and I've been making each page individually which takes a really long time to do, I asked a question similar to this and it was brought to my attention that you can setup a way to automate the design process so all you need to do is input your data.
Can someone please explain in as much detail as possible how you setup your xcode files/code to automate such a process
So for example I would just enter the page text and it would automatically put my standard background picture in and add a scroll view and appropriate buttons etc.
Thanks
You could make one master view that contains all the controls that you need: standard background picture, scroll view, appropriate buttons, etc, and make any subsequent views that you create inherit from this view, so that they all contain those controls.
You could also use just one view and work with multiple instances of it, one instance per page. Just make sure to have a Text property on it, or a constructor that takes in your text string, so that you could set it to a different text on each page.
Xcode project templates and file templates are pretty easy to make, with a few caveats.
Check the answers to these questions:
Add new templates in Xcode
Change templates in XCode
Also take a gander at these handy tutorials:
Custom Xcode Templates
Xcode: How to customize the existing project templates
It sounds to me like your putting your data into your views (pages). That's a big design error. You need to employ the Model-View-Controller design pattern and separate your data from your views. That will make it easy to create one view (template) that you can reload with data to display each individual recipe.
The first thing to do is to separate your data from the view. You need to have the recipes stored in an array, dictionary, Core Data etc and then wrap that data in a dedicated object. The second thing to do is to create a dedicated view to display all the recipes. As the user moves from recipe to recipe the app will simply remove and add information to the same view as needed.
I would recommend Cocoa Recipes for Mac OS X: The Vermont Recipes, Second Edition because it addresses these issues and it uses a recipe type app as its example. It's for Cocoa but the basic principles apply to iPhone apps as well.