Out of the various stock UIKit classes, which ones are considered focusable by default by the Focus Engine on tvOS?
Per David House on Big Nerd Ranch, the following UIKit classes are focusable:
UIButton
UITextField
UITableView
UICollectionView
UITextView
UISegmentedControl
UISearchBar
Note that this is different from which classes conform to the UIFocusEnvironment protocol; the above are what would return true on canBecomeFocused
Related
I want, using the storyboard, to add a UIBarButtonItem to a UIToolbar, but only for width:Regular and height:Regular devices.
In the bottom of the storyboard, I activate „Vary for Traits“, and select width and height, so that only iPad devices remain.
If I draw an UILabel to the canvas, the attributes inspector shows me, as expected, 2 „installed“ fields, one for all devices (unchecked), and one for wRhR devices (checked):
However, if I draw a UIBarButtonItem to my toolbar, these fields are not shown.
Does this mean that a toolbar cannot be customized depending on size classes?
Briefly speaking, size classes, or vary for traits, only work for UIView objects, but UIBarItem/UIBarButtonItem inherits from NSObject, not UIView.
I find AppKit's NSMatrix and NSButtonCell classes useful for grids of buttons. I wonder why Apple never created these counterparts for UIKit?
The equivalent in iOS is UICollectionView. It's much more flexible and useful than NSMatrix, here is a tutorial.
Now that we have NSTableView and NSOutlineView that can have regular NSView objects as their cells, what about NSBrowser? That is can we use regular NSView objects as cells in NSBrowser?
Short answer: No, not yet
NSOutlineView is a subclass of NSTableView so both of them got the upgrade to be able to use NSView objects as cells in Mac OS X 10.7. This is specifically called out at the beginning of the documentation for NSTableView:
Table views are displayed in scroll views. Beginning with OS X v 10.7 NSView instances (most commonly NSTableCellView instances or a subclass) are supported for rows and columns. Alternatively, NSCell subclass instances can be used for each row and column item.
On the other hand for NSBrowser it says specifically:
This class uses the NSBrowserCell class to implement its user interface.
What's the difference between NSView and NSViewController is XCode 4 Cocoa application?
NSView is just the view in MVC. NSViewController has a NSView (or a subclass of NSView), and also contains the code for the controller in the MVC model.
I may be wrong, since I'm drawing the answer from my experience with iOS, but I think it should be about the same for OSX.
What exactly is the point of adding a UIViewController in IB? There is no way to add code like you can if you create a viewController in Xcode? And if you can what is the advantage of doing it in IB.
And isn't the whole point of a MVC to seperate code into "modular" parts so why would add a ViewController in IB
Sometimes all you need is a UIViewController. But most times you would create a UIViewController subclass of your own (in IB).