Positioning UISearchBar above TableView in .xib - xcode

I'd like to make it easier for users to access the searchbar. Currently, the searchbar is above the tableview and when a user scrolls the tableview, the search bar scrolls off screen with it. Is there an easy way to position it above the tableview so it will always be visible?
I am using .xib files instead of the storyboard b/c I'd like my app to be compatible back to iOS 4.0.

Well what you could do is just place a search bar above the table view in your XIB. Or just move the search bar you've (presumably) got in your table view's header view at the moment and put it above the table. You'll also have to shrink the table by 44 pixels (the height of the search bar) and move it down so that the search bar is above it.
If you go for deleting the one in the table view's header view and creating a new one then just make sure you hook it up correctly to whatever it is that's currently using it (i.e. probably an outlet for the search bar and its delegate).

Related

How to show scroller indicator in NSTableview when scrolling , hide when not scrolling

I am new in MacOS ,I want to show scroller indicator in NSTableview when scrolling , hide when not scrolling.
I am thinking to get the delegate of NSScroller , So i can detect when it scrolls,then hide/show it . Please help
Per the NSTableView reference page:
Table views are displayed in scroll views.
A table view itself doesn't know how to scroll. You have to put it inside a scroll view in order to scroll the table. If you're used to iOS and UIKit, that's a difference; UITableView inherits from UIScrollView, so on that platform a table view is a scroll view. In a MacOS project, if you insert a table into a view in Xcode's nib or storyboard editor, Xcode will actually insert a scroll view that contains a table view so you'll already have what you need. If you're creating the table in code, you'll need to also create the scroll view yourself.
Looking at NSScrollView, there's a property called autohidesScrollers which is...
A Boolean that indicates whether the scroll view automatically hides its scroll bars when they are not needed.
So, to get the behavior you're asking for, you need to set the scroll view's autohidesScrollers property to YES.
Of course, you can set that in the storyboard editor too, but again you need to look at the options for the scroll view, not the table view:

iOS TableViewController Scrolling away content and navigation bar under status bar

I'm using a TableViewController and I've added my own navigation bar on top to match the other tabBar pages that I have.
I had to place at the top an empty view to lower the starting point of the table view so it wouldn't cover my navBar, which was already annoying.
Now it looks fine except that when I scroll up my list both navBar and TableView go under the status bar.
I want my navBar to stay where it is and the TableView not to go under the status bar when scrolling.
For starting I can't add any other stuff in my scene if not under the table view and i get that that's causing the nav bar to follow the tableview up so that's part of the problem..
Xcode 7.1 swift 2.0 iOS 9
When creating this kind of structure (table + other elements), the best approach is to actually have a ViewController that contains a TableView and additional elements (like your navigation). Do not try to put elements, that are not part of the table itself inside the table.
Here is an example of the structure, where I have intentionally coloured the custom view (in your case the navigation) orange. As you can see, it is outside the table. This way the showing and scrolling of the table is completely separated from the other elements.
you can try self.edgesForExtendedLayout = UIExtendedEdgeNone;

Xcode tableview hidden behind navigation bar

Can anyone please tell me how to fix the following issue.
I am building an iPhone app using Storyboard. I have a Navigation Controller as root view and off that a view controller. On this I have a few buttons that when clicked takes you to a table view controller. All fine and well, but when I link the buttons to their respective table views, the top navigation bar obscures the top cell in the table view controller.
Does anyone know why this is happening and how I can fix it?
Also it seems to have thrown off my layouts from the view controller from which they inherit.
See attached image for a better explanation perhaps.
I believe this is the intended behavior when using the translucent navigation bar. It's semi transparent specifically so that you can see items pass behind it (e.g. a table scrolling). If you don't want this, changing the navigation bar's style to opaque should solve the problem.
Since I wanted to keep the translucence, I just added a UIView between the navigation controller and the prototype cell (width of the view, height 60). That way the first cell in the table starts beneath the navigation bar but I can still see the scrolling underneath.
This is a bug/feature in IB when you use a translucent navigation bar, the content view runs under the navigation bar. For non transparent bars the content view begins after the bar. If your content view is a UIScrollView (UITableView is a descendent of UIScrollView) the content will be automatically scrolled so as to not be hidden under the navigation bar. So the problem only exist in IB when you run the app everything should be ok.
You just need go to the Navigation Controller properties, then Simulated Metrics, and change the Top Bar to be a Transluscent Navigation Bar WITH PROMPT. And that should be it. No need for that extra UIView

Keep search bar fixed position while scrolling tableView

How can i keep the uiSearch bar i created in Xcode 4.3.3 fixed on top while scrolling the table view?
Any thoughts?
EDITED:
If u have used the Interface builder to add the search bar, make sure that it is not added as the subview of the tableview (this makes the search bar as a part of the table, which scrolls along with the table). Checkout the link below, and avoid it. This link shows how a search bar becomes a subview of the table. This is not what u want. Just drag the search bar outside of the Table view in ur interface builder, so that it becomes a part of the view.
I have added second image to show how u can find the solution to ur problem.
If u want to add the search bar programatically, then just add it as-
[self.view addSubview:mySearchBar];
Set the frame of this search bar accordingly.
how did you create them in the nib file? do not put the search bar on the UITableView. they should be separated.You can put the search bar at the top of the tableview but not on it.

SplitView not resizing NSTableView in subview correctly

I have a 10.6 app that I am building on Lion with Xcode 4.3
There is a horizontal split view in the main view, containing the following:
The top view contains an NSSearchField with an NSTableView below it.
The bottom view contains a WebView.
I have it working, but when I resize the split view the top view behaves oddly.
What I want to happen is for the search field to remain where it is, the tableview to remain where it is, but to expand if the split view is dragged down. If dragged up, I want the webview to overwrite the search field and table view.
You can see what I mean in this clip: http://dl.dropbox.com/u/160638/Work/TENSOFT/resizemostlyokay.mov
This keeps the things in the right place when I drag up, but doesn't expand the table when I drag down. The view is expanded, but not the table.
So, I changed the autosizing constraint on the table view / scroll view to make it expand when the view is resized. This is what happens: http://dl.dropbox.com/u/160638/Work/TENSOFT/resizeproblem.mov
When the split bar is moved upwards the table view is moved upwards inside the top view until it overwrites the search field. It doesn't move back when the bar is moved back down.
I cannot find a way to make this work by changing the autosizing constraints. This is usually pretty easy stuff, so either I'm missing something obvious or...?
Has anyone seen this behaviour before when creating SL apps on Lion with Xcode 4.3?
FYI, if I replicate this in a new 10.7 project using auto-layout everything works fine.
Regards
Darren.
When you allow an NSSplitView to make one of its subviews very small so that the subviews effectively overlap you get layout issues and this is one of the reasons that Apple introduced auto-layout (watch the WWDC video about auto-layout and I think they demo this problem near the beginning).
If I were you I'd set a minimum size for the top pane so that, for example, it stops resizing when it is 100px high. You can then allow it to collapse so that the user can still show just the WebView.

Resources