NSTextView won't support redo and undo in Cocoa app - swift

I searched this topic and never was able to find any answers to this.
When I make a new project in Xcode and I place a NSTextView as part of an
NSScrollView in my app, everything works fine as it should. The only thing is undo and redo won't work. It just does the funk noise
Copy, Cut, Paste all work as expected tho.
I get the same result if I do an app from scratch (no Storyboard) and code it in. Still undo and redo doesn't work?
Anyone knows what is the deal with this?

When you create a Cocoa app project that doesn't use the document architecture and add a text view, the text view does not allow undo initially.
Select the Allows Undo checkbox in the attributes inspector to turn on undo support.
One more thing. When you add a text view to a storyboard or xib file, the text view includes its own scroll view. You don't have to place the text view inside a scroll view.

Related

Can't move focus from table view to adjoining button on tvOS

I have a single ViewController which contains a Table View on the left and a few labels on the right. Navigating through the table view entries works fine (up/down). Focus is no problem there. Even the related text in the labels is updated just fine using tableView:didUpdateFocusInContext.
The interface looks like this:
However, the button on the right ("Jetzt ansehen") never gets focus. When I use the debugger (as suggested in the official documentation), it doesn't include the button in the focusable area at all:
I really tried to solve this using UIFocusGuide, but I have no real idea how to accomplish that, yet.

Why is this iPhone app's "quote" button not replacing the Text View's lorem ipsum?

I am working through the "iPhone introduction for programmers" tutorial at http://www.raywenderlich.com/21320/objectively-speaking-a-crash-course-in-objective-c-ios6, and my present project is at http://JonathansCorner.com/project/Quotes.tgz. The tutorial's focus is on providing an iPhone app that randomly displays one of several quotes in a Text View when you click on a Button. Later on the tutorial pushes further by defining properties and storing and retrieving XML, but I'm at the first "Let Her Rip!", which offers the first attempt running the app within the simulator with some increment of functionality, which should be that when you click a button, a randomly pulled quote appears. The text should be read-only as far as editing with the keyboard is concerned.
The behavior I am presently observing is that the simulator displays the Text View's native lorem ipsum. It continues to do so after clicking the button, and when you click on the Text View, it pulls up the keyboard and edits it. I've checked my wiring, and I don't see where I failed to duplicate what the tutorial shares. (The tutorial references a ViewController.[h|m]; is it a problem that I have a prefix before everything that takes a prefix when creating the project, e.g. CJSHViewController.h?) It behaves like one would expect from following the tutorial up to that point but not wiring event handling up or turning off edit mode for the Text View.
Any help or nitpicks would be welcome. (I am a programmer just beginning in iOS, so if there are "programmers new to iOS development" errors, I may have made at least one.)
Thank you,
The function you wrote for changing the text in the text view is working perfectly. The problem is with your IBOutlets. You never linked the outlet for the text view to the text view and consequently when you assign new text to it, it has no where to go.
Ok checked your project and found the error:
The problem is that quoteText is not referenced on the storyboard file so...
Go to your .storyboard file and drag the + symbol from the Connections Inspector to the view controller as shown on the screenshot when you click up a context menu should appear with the following options
quoteText
view
Of course you click on quoteText
Hope this helps

UIButton doesn't display properly

I added a UIButton to a view in my application. Its a custom button, with two different images for its default and highlighted state. I have 2 other buttons on the view that are very similar but provide different functions.
However, my latest button won't display at all. I've clean the project as suggested in another question and it still won't display. Whats doubly weird though is that if I click the area of the view where the button should be, the IBAction is called and the UITextFields are cleared as if the button was there. Its as if the button is being created without its graphics being displayed.
Does anyone know what might be happening here? The button looks as it should in IB.
Thanks, Jack
Go to the Organizer window, select the Projects tab, select your project in the list and then delete the derived data folder by choosing "Delete…" in the window.
If that doesn't work, check if the images are included in the target. Select the image files and look in the info editor (the Files tab — the left one) if it's added to the target.
Hope that helps.

Why isn't my keyboard appearing?

I have an application that allows the user to edit multiple text fields and views. Rather than mess around raising each view to the top when the keyboard is active, I decided to instead make one textView for editing and hide/show it when input is needed, then transfer the data when it is done. To move focus to the new textView, I call its becomeFirstResponder method, and lo and behold, the cursor goes to the right place. However if I use this method, the iPhone keyboard does not appear. I have no idea why. Can anyone explain, and tell me how to make the keyboard appear? All the other questions I've looked at seem to indicate that setting becomeFirstResponder for a textView ought to make the keyboard come up.
-Ash
Is Hardware -> Simulate Hardware Keyboard enabled?
Are you doing this whole thing programatically or using Interface Builder as well?
If so are the IB connections setup right?

iPhone Table View Data Edit Pane

I have an application I'm working on, and I need the user to be able to add new "Shows", "Movements" and "Dots." These are all represented by classes. At the root of the application, all the shows are shown, the user can click on the show, see the movement in that show, then tap on a movement and see the dots in the movement. It works beautifully.
Now, I need the user to be able to add and edit these instances of these classes. The way I am thinking this will work is when the user clicks on the "Add Show" button (Or the "Add Movement", etc) a new view will be pushed onto the Navigation Controller. This works. When the button is pressed, a new instance of the show class is created, and passed to the new view controller. This also works. If the user wants to edit the show, then they will hit the edit button for the row, and the instance of the class (which already exists) will be passed to new view controller, and the user will be able to edit it (It should use the same view controller for adding and editing)
My question is, in the examples I have seen, it is always really dirty to create the editing view. The edit view is a table view with each row having some sort of control. Usually it is a UITextField, but it may be a slider, and it may be one where another view is popped, and the user needs to check one value. (This is similar to the address book application when adding and editing a contact)
Is there any way that is cleaner than just manually going in and creating a bunch of arrays to hold what custom table view cells need to be at what row? This gets very messy, very fast. I can do it this way, I just was wondering if there is a better, possibly faster way.
To my knowledge there's no structural solution to solve this. I'm afraid managing the cells with child UITextField or other controls yourself is the only method. This indeed gets dirty and painful very fast, I certainly feel your pain.
Although it doesn't exist, it would be very convenient if Apple added out of the box editing cells to the SDK, similar to the different normal cell styles. I haven't come across an open source project that addresses this issue, but it might exist.
If you do find a better/cleaner method to handle these situations, be sure to ping back.
as far as i know, editing mode is the only way to make the changes you describe (if i understood correctly). I agree that it doesn't seem like the most elegant approach.
http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/ManageInsertDeleteRow/ManageInsertDeleteRow.html#//apple_ref/doc/uid/TP40007451-CH10-SW19