hi i have implemented UIPageControl on top of UIViewController , and i'm trying to implement at the vary left side of the page control a UISearchBar and UITableView
i spend so time on the internet looking for a solution .
what i need to do ??
to put the UISearchBar on UIView or there is something else?
Check out UISearchDisplayController and the related sample code. It won't work right out of the box. Especially if you want to have a black background rather than a table view when you start.
If UISearchDisplayController doesn't work you can do use a UISearchBar on a UIView and respond to the UISearchBarDelegate in your controller. By implementing searchBar:textDidChange: and showing a custom UITableView when text is entered and then hidden or removed when the search field is empty you can provide the desired functionality.
Related
I'm trying to replicate the functionality in the Facebook for iOS app where the UISearchBar in the navigation bar is 'shared' between view controllers. For example, tapping on the search bar on the home News Feed view appears to push a new view controller and 'transfer' the search bar to the new view controller. The search bar size is resized and animated alongside view controller transitions (including when using the 'interactive pop' transition, as depicted in the screenshot below). This behaviour is exhibited in various ways throughout the app. Is there a standard way to achieve this behaviour in UIKit, or are Facebook somehow applying custom transitions/animations to the navigation bar and search bar?
Having had a quick play with it, first I'd say that the main screen is split into several parts. Its hard to know what those objects are, but at a guess, I'd say theyve got a UIViewController that just contains the search bar and other 'navigation' elements. Below that theres another UIViewController that contains the newsfeed, and that is a flexible space in that various other things (custom) can happen in there. Both of these are likely set as 'ChildViewControllers' within a parent ViewController. This allows you to for eg, get several UIViewControllers onto the same UIViewController space in interface builder.
Their search bar itself is highly customized and might not even be based on a UISearchBar. Theyve probably just created a fully custom UIView with a UITextView to type into and lots of other custom animation going on. Still, you can achieve much of what they are doing by using a UISearchBar.
So going this way, the search bar remains the same search bar, while content changes below. If you for eg do a search, then the search results appear below, but that same UISearchBar stays visible above.
An alternative approach that I might do if not using ChildViewControllers (I've gone off that method), would be to simply use UIView based objects within a single UIViewController. So a UISearchBar at the top, probably within a parent UIView. And another UIView below to contain the feed and everything else. Again, just search using the single UISearchBar and change the contents of the UIView below as required.
I'm newbie with iOS and asking for direction.
I want to make a page which contains navigation buttons on top and when tap load different UICollectionView's as you can see on the app screen taken from "Fancy". Also buttons line have to be fixed on top while scrolling down. (just like in the screenshot)
Which is the right approach?
Base class to be UICollectionViewController and adding as SubView
Using UIScrollViewController?
etc...
Thanks in advance.
Base class should be UiViewController implementing UICollectionViewDelegate
UIViewController <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
Create different NSArray for each Category of your project as datasource of UICollectionView
use UISegmentedControl for switching the datasource of UICollectionView and reload UICollectionView to display different content.
You can customise your Segmented Control as you wanted.
Implement UITabbarController for the bottom bar to enter any other views
There are a number of ways to go about this. The simplest would probably be to use a UIViewController subclass whose view contains a UISegmentedControl subview (for the navigation controls) and a UICollectionView subview for the content.
http://s7.postimg.org/suz457l23/IMG_0092.png
I want to use a UISearchBar that doesn't move, like in Apple's Contacts app. I also want to these components at the same depth, and I don't want the search bar in the tableview header.
UINavigationBar
UISearchBar
UITableView
When I try to attach UISearchBar below UINavigationBar in storyboard, interface builder doesn't show me suitable guideline. The guideline only generates when in tableview.
Is there no way to attach the search bar below UINavigationBar without programming?
I'm also searching an elegant way to build the search bar..
What I have now is a UINavigationController, inside which I have a UIViewController.
This UIViewController contains UISearchBar and UITableView. You can program the search bar on top and tableView below it.
vborra's link also helps.
It is easy to do what you are looking for, UISearchBar is somewhat meant for this. See the tutorial Here: http://www.appcoda.com/search-bar-tutorial-ios7/
I'm having a strange issue with my UISearchDisplayController. When the search display activates the frame of the background fading view and the tableview are incorrectly overlapping the UISearchBar. It appears the results tableview is not taking the offset for the UIStatusBar into account.
The ViewController is using auto layout. Since the application does not use any opaque bars, the view controller does not extend any of its edges.
Extend edges under top bars = NO,
under bottom bars = NO, and
under opaque bars = NO.
Here is the initial layout:
This is what happens when the search display activates:
And finally, here is the resulting output of the search:
I solved my own problem. A hard lesson learned. After a few hours of thinking "It really shouldn't be this hard." I realized that my instance of UISearchDisplayController was not properly linked to the API provided property of its parent view controller. If you're using UIStoryBoards / Interface Builder be sure to click on your ViewController and view its provided outlets in the inspector. If you see this:
Then something is wrong and you're going to run into issues just as I had. What you'll want to do is to click in that empty circle and drag to your instance of the Search Display Controller. If things are linked up right you should see this:
I foolishly didn't pay attention to this and created my own IBOutlet to reference the Search Display controller. That caused IB to null out the API provided outlet as a UIViewController can only support one Search Display Controller. If you need me to clarify anything let me know.
Imagine, there is a UIViewController with a UIScrollView in it. At the top of the view there is an UIImageView, some UILabels and other things. Furthermore, there is a UITableView which content is Dynamic Prototypes. I attach a picture to make it clear:
I haven't got a static amount of cells in the UITableView so it could be scrollable. My problem is the following: the UITableView scrolls in itself but I want to scroll the whole View. What is the best possibility to do that?
Possible solutions I've founded today
1) The first thing is: I create a UITableViewController and declare a header section in which I include all my labels, images etc. programmatically (I would love to use the interface builder for that...)
2) Another solution is to calculate the height of the view. I tried the best to do it like this way - but: without success. If this is the best way to do that: Can anybody give an example?
I would ditch the UIScrollView and just use a UITableView. You can add a UIView object as the tableHeaderView of the UITableView just by dragging it in in Interface Builder. Now since everything is part of the UITableView hierarchy, everything will scroll together as expected.
You could also try setting delaysContentTouches to NO on your scrollView. Depending on your setup, this may make the scroll view respond to the touch first instead of the table view.
From Apples UIScrollView Docs:
delaysContentTouches
A Boolean value that determines whether the scroll view delays the
handling of touch-down gestures.
#property(nonatomic) BOOL delaysContentTouches
Discussion
If the value of this property is YES, the scroll view delays handling
the touch-down gesture until it can determine if scrolling is the
intent. If the value is NO , the scroll view immediately calls
touchesShouldBegin:withEvent:inContentView:. The default
value is YES.
You'll have to (as you've mentioned) add the UIView containing the image and buttons to the actual UITableView. Embedding it in the scroll view will produce the undesired behavior that you're seeing.
I would recommend returning the UIView as the header view for the first section of your table view. You can do this by implementing the UITableViewDelegate method:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
If you maintain an IBOutlet to the view containing your image/labels, you can return it here.
this is same demo i hope its helps you from iphone sorce code library
http://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html
thank you