Scrollable list of text fields (a form) with tab navigation - objective-c

Goal: Implement a vertically scrollable list of custom editable items (a text field + a button). The list and its items should autoresize in the horizontal direction. Tab / Shift-Tab navigation should navigate between the text fields.
Current solution: A one column NSTableView with view-based cells. But there is a problem with the Tab navigation. NSTableView handles the Tab key in its own way. I've tried all the subclassing hacks from SO, but failed to implement a normal Tab / Shift-Tab navigation between text fields.
Alternative solution: I've also tried making a custom stack view inside NSScrollView, but failed to make its subviews to autoresize.
Question: Looking for an open-source example or an advice from those who done such a thing before. Thanks in advance!

Related

How to display show/Hide button in highlight regular mode of NSOutlineView?

How to display show/Hide button in highlight regular mode of NSOutlineView?
I have a grop item at the top of NSOutlineview. I try to display show/hide button in that group item, but I can't find any method to do it. The source list mode can display it but regular mode doesn't.
Is it possible to display show/hide button in highlight regular mode of NSOutlineview?
thanks for helping
This behavior is specific to the source list appearance. There is no public API for getting around this, as it's an intentional enforcement (on Apple's part) of standardized appearances. You could dig around in the headers to look for a way to "hotwire" things, but use of private API bars you from distributing your app through the App Store.
The easier (non-private-API-using) route is to create your own cell view with a borderless button with show/hide title. Use a mouse tracking area (see NSTrackingArea) on the cell view (the superview of your button) to set the button's alpha (via its animator) to fade the button in/out on mouse in/out. Your button would tell the outline view to expand/collapse its cell view's represented item (the easiest way would be to define an outlet to the button via your custom NSView cell view class and configure the button's target/action when the cell view is created for the item).

Swipe to see options in iPad

How can I implement swipe to see more options? There are lot of libraries that I could readily use, but they all are designed for iPhone apps. In iPad you have a lot of space, and I want to stack the buttons vertically instead of horizontally.
Is there any library for this? If not, how should I go about building this as a custom cell?
I tried building a custom UITableViewCell class which adds a UIScrollView, but it's not the same as showing the buttons beneath the cell.
Based on your inputs I have created a simple custom cell with basic functionality of swipe to see utility buttons and of course buttons stacked vertically.
What I did was, add a UIView beneath the cell's content view and positioned at right. Now depending on the number of buttons provided each button's height is adjusted accordingly. And delegates are provided for button clicks.
Swipe gestures are added. On swiping left it will animate and shift the cell's content view to reveal the button view. On swiping right it will reset the cell to original position.
You can customise it from here onwards as you wish :)
I have uploaded them over here : https://github.com/srikanth-vm/GSSwipeableCell

iOS layout: alternative to tabs?

I'm working on a iPhone app which shows an mobile webform in a UIWebView. I'm using a default iOS layout with a navigation and tab bar.
The mobile webform is displayed in a UIWebView in the white area. Since the webform has a lot of input fields, we really need as must space for it as possible. Because of this, we are planing to remove the tabs in the bottom. Over time, there will be more tabs/sections, so it is not a solution to just add a button for each section in the left side of the navigation bar. On a iPad a popover could easily be used to handle this.
Is there a standard iOS layout mechanism to handle this change of sections/views without using tabs?
You could do something long the lines of Path or the new Facebook app and have the "table of contents" behind the Navbar and the navbar slides away (along with the child view) to reveal it. When done right (ie smoothly) I think the effect is really cool.
This would also work great as you add more and more options, since the table could just scroll.
Here is a framework that might be you started: http://www.cocoacontrols.com/platforms/ios/controls/iiviewdeckcontroller
I would consider replacing the navigation bar's title with a control that lets you switch between tabs. You can assign the bar's titleView property to a control or a button and it will generally do the right thing.
If you're limited to 2-3 tabs, you could simply use a UISegmentedControl.
If you want more, you could use a button which, when tapped, pops up a view that allows you to select the view you want. This could be a modal table view, or you could slide up a UIPickerView from the bottom of the screen, similar to the keyboard.
I use this technique in an app of my own, screenshots here. Tapping the button cycles between views (in this case, I'm changing the contents of the table cells); tap-and-hold slides up a picker.
Another possibility would be to arrange your different forms on pages in a scroll view with a page control at the bottom, à la Weather. The best option, though, if you’re going to have a particularly long list and want to keep your screen real estate, is probably the FB/Path-style sidebar table.
I ended up using a UIActionSheet but I think it in other situations would be more stylish to use a controller like the IIViewDeckController.

Could the view to be pushed up when the keyboard occur?

I have created some textfields at the bottom that required users to entry. Is there any method that can push up the view automatically when the keyboard occur?
See Apple's Moving Content That Is Located Under the Keyboard, or this implementation based in Calculating Area Covered by Keyboard.
Basically you have to mount your view on a UIScrollView and add a bottom content inset with the same height than the keyboard. Then scroll using setContentOffset:animated:. This is a generic solution that you can reuse.
A more simple but non generic way is, if you have enough space at the bottom of your view without editable controls, you just scroll to a fixed position for each edit box.
use the -contentoffset property of your view.

NSCollectionView as NSPopUpButton "drawer"

I would like to have something similar to the "List mode" of the stacks in the Dock.
But it should have the behavior of NSPopUpButton, in terms of displaying the selected object still, when the "drawer" is collapsed.
Each row should contain an image and to text columns.
How would you realize this?
Maybe subclassing NSPopUpButton, to display a CollectionView?
Or having an ordanary button and attaching a window containing a CollectionView to it, when clicked?
Oh and this up and down bars, instead of scrollbars on the side - how's that done?
Why not use a regular NSPopUpButton whose menu assembly is replaced with subclassed NSMenu/NSMenuItem that draws things the way you want? You get all the scrolling behavior for free.
If you insist on using NSCollectionView, however:
1 - Don't subclass NSPopUpButton if you're planning on popping up anything other than a menu. It's built to display a menu. Just use a regular NSButton and manage its -state (NSOnState while the collection view is displayed; NSOffState otherwise) manually.
2 - You could show a borderless transparent window (many examples available online) with a standard collection view / scroll view assembly minus the scroll bars. The borderless window could host the up/down areas (which can be simple views with NSTrackingAreas to detect mouse over). These areas could manually scroll the NSScrollView a bit every n milliseconds using an NSTimer while hovered.