How would print what is in my NSTableView? The View uses core data so everything is stored and can be grabbed as an NSArray. But how would I go about printing it out? At the moment when you click the print button it just seems to take a picture of the view and print that.
Yes, this works exactly as documented. The view is asked for its PDF representation (which, for an unmodified table view, is exactly what you see on screen), then this gets printed.
A view's drawing can be customized for printing versus on-screen drawing, but for a table view, this is more trouble than it's worth.
It might be easiest to generate an HTML representation of the table, then print that. You can use WebKit or just a plain NSAttributedString and off-screen NSTextView. The trick there is to generate the HTML, create an attributed string with the HTML data (there's a method just for that), then hand that to the off-screen text view. The text view would be sized as desired, then you just tell it to print. This gives you control over pagination as WebKit doesn't currently support the print-specific parts of CSS (in other words, it's "screen-only").
What I've done is taken the data and drawn it to a NSView based object in a way that the end-user would want to print. The user then prints that. it's in the docs.
I like Joshua Nozzi's idea, probably much simpler than custom drawing...
Related
I'd like to show information in a second view that's contextualized to what's appearing in the first view. To do that, I'd like to get just the text that's scrolled into view in the NSView. As in the picture I've attached, the whole document is A. The portion that's visible is B. I'm writing this using Objective-C and Swift, so a suggestion in either language would be welcome. Thank you.
In the app I am currently developing, I have to implement a screen which allows the user to ask a question. This screen contains a UIImageView next to the UITextView, taking up a portion of the space. It looks like the below image.
My question is, how can I wrap the UITextView text around the UIImageView, so that the text won't be in a block, but flowing around the UIImageView?
Thanks in advanced.
I don't think you can do this, unless your UITextView was a rich text or HTML editor, with the image embedded inside it. Basically what you're asking for is a non-rectangular UITextView. To the best of my knowledge, that is impossible in iOS, unless you were to create something brand new from scratch, which would be extremely complex. I have seen plenty of UILabel-style controls that can display HTML-like text, but not edit it.
EDIT: this might help: http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
Unfortunately that's not a trivial issue as the UITextField does not provide any functionality that would be useful here.
However what you could do is to implement your own text view using UITextInput (for text input) and Core Text (for text display) and then define the drawing rectangle for Core Text (you can read more on Core Text here) from a custom CGPath that would exclude the images frame.
It does sound a bit complex (insane, perhaps), however as (nearly always) there are open source solutions that already found a solution. The OmniGroup framework contains custom text input controls based on Core Text and UITextInput. They're licensed under MIT License (well, moreless) so you should be just fine.
I encoutered an essential problem while making an iPad app, where u HUGE amount of text will be displayed.
I need to create blocks of text that can line break and also be linkable(for calling certain functions on each block). I thought that Core Text should be used.
Which is the way to assign the position of touch with necessary block of text?
and does anyone has any examples? google is poor on it, when it's about working with some amounts of text.
You can use a transparent button in overlay of the text.
You can not make your text linkable as in a html page. You can do this feature only in Webview.
I can make a single row IKImageBrowserView by setting the
[imageBrowser setContentResizingMask:NSViewWidthSizable];
but in this case while i drag an image inside image browser to rearrange it, the drop place highlights with horizontal line(vertical line expected).
how can this be changed?
Many thanks.
There is no defined way to do what you want.
You may be better off writing your own custom view where you can control every detail of how things are drawn. In general, Apple's controls are "as-is" and unless they provide an explicit way to control behavior or mention that you can custom an object in some way, don't count on being able to do it easily (if at all).
I would also suggest heading to http://bugreport.apple.com and making the enhancement request - it would be best if you attached a sample application demonstrating the behavior.
EDIT: You could also try out the NSCollectionView to see if it might work for you.
I was wondering if anyone could tell me if there is a method in Cocoa that will display information (images) on screen when a button is pressed. What I mean is NSLog "prints text" to the console is there a method that displays images just as easily like would -(void)drawView do it? Is it just setNeedsDisplay? I hope this makes sense. I am essentially wanting to know if I can call something that will display an image as easily as you can display/print text to the screen/console.
The Console is text-only, so no, you can't print an image to it the same way you log text. The closest equivalent is to export the image as TIFF data and write that data to a file in the temporary directory.
As for setNeedsDisplay:, that tells AppKit that the view should be told to redraw the next time the window redraws its views. (In other words, it sets the view as needing display—exactly what it says on the box.) Usually, this is because you've changed the model object(s) that the view displays, either by replacing them with other objects or by mutating one or more of their properties.
You would need to have a view to display; an image view would certainly qualify, but if you're looking for the image equivalent to NSLog, this isn't it, unless you don't mind either making a dedicated window just for showing this image or temporarily putting a image view into one of your real windows.
You should take a look at Apple's NSImageView Class Reference.
This a class you can use to display an image in Cocoa.
setNeedsDisplay is a NSView method that tells the graphics renderer it needs to redraw the image because the data has been modified. Presumably because you are using something like Quartz and you have called some custom drawing code. If you are drawing bitmap images then you probably won't need to use this.