Touches Began method not called in my custom UISearchBar class - objective-c

I am adding a UISearchBar which was initialized using a Custom Class to a UIView. And I have overridden the touchesBegan() method.
And I have enabled user interaction in the UISearchBar. But still touchesBegan() method does not fire when clicked on the search bar.
Any Idea why touchesBegan() function is not called?
It'll be great if anyone could help me out.

you have to make sure to set the delegate for UISearchBar. In doing this, in your .h file, type after UIViewController. Then in your nib file, make sure to connect your searchbar to the name of your searchbar found in the Referencing Outlets section. Hope that will help you.

Are you sure you have set the custom class in Interface Builder as UISearchBar?

Related

Cannot assign UITableview in xib to custom tableviewcontroller

I know this problem has been tackled quite a lot over there but I stil cannot find a solution in this case.
Basically, I have a tableviewcontroller called "TableViewController" that inherits for some reason from another class called "BaseTableViewController" (which inherits from UITableViewController). Everything works fine when I initialize an instance of TableViewController. I have my tableview in full screen.
Because I added a searchbar (which is working) and needed more room for other elements to be displayed, I want to insert this table view inside a UIView. I created an other UIViewController ("MainView") with a xib file and I added a tableview object as a subview.
My problem is I don't know how I can assign this tableview to my custom class I was using before ("TableViewController"). I tired to import the header file (TableViewController.h) in the header file of MainView.h but it does not seem to solve the problem.
Would anyone have an idea how I could link the tableview inside a UIView to a custom tableviewcontroller?
Thanks!
If it can help, below is my mainview with a tableview object I would like to be linked to my custom tableviewcontroller in order to have it with my datasource, delegate, search bar, etc. I cannot insert "tableViewController" in the custom class.

UICollectionViewDelegate not firing on UICollectionView subclass with custom UICollectionViewCell and NSObject controller

I have subclassed UICollectionView and assigned its delegate and datasource to an NSObject class. I use a custom UICollectionViewCellwith a .xib to construct the collection view's cells. The project can be found here:
https://github.com/JeffModMed/CustomUICollectionView
As you'll see, the datasource methods are working fine, but didSelectItemAtIndexPath and shouldSelectItemAtIndexPath are not called when the user taps on a cell, which leads me to believe there's something with UICollectionViewDelegate. The only other possible problem area I can think of is that there's something wrong with how I'm using the custom UICollectionViewCell class or registering its .xib file.
Note: Please don't answer suggesting that I use UICollectionViewController as an alternative: the code has to be done this way for incorporation with a larger project. Thanks in advance.
In the MMFilterTagCollectionViewCell.xib, select the cell and enable the User Interaction Enabled option.
In the MMFilterTagCollectionView.m file, comment out this line:
#synthesize delegate;

Iphone : what do I need to do to a nib file to an exisitng object

I have tried using an outlet to connect my tableview controller to my object, setting the nib name in IB and setting the class in IB but it still wont link? I know this as im trying to set my table view to 'grouped'
Thanks very much.
It's a little unclear what the problem is. Do you have the outlet visible in IB, but it's not letting you draw a little line to the table view? In that case, double check the class of the outlet. It should be the same (or a superclass of) what you're trying to hook up to it.

Cocoa Touch UITabBar action on tab switch

I have a UITabBar with a number of UITabBarItems. I've assigned a different view controller to each of these.
I want to load some data etc., when each button is clicked. Therefore I will like to know where to put that code? I tried implementing viewWillAppear and viewDidLoad in the view controller but those didn't get called.
I know that when you assign a delegate to a UINavigationController, the component UIViewController delegate methods are not called. It seems likely that the same is true of UITabBarController.
I would try implementing the UITabBarControllerDelegate protocol and implementing the tabBar:didSelectViewController: method.
Are you sure your custom controllers inherit from UIViewController?
Don't forget the signature for the viewWillAppear is viewWillAppear:animated:
I'm working off the beta 5 right now, and it works just fine (I'm also using a TabBar).
Write your code in viewdidappear function.but i didn't try

TextFields not loading in subclass of NSWindowController

I am working on a second preferences style panel (but preferences related to a specific document.) My myDocument file is getting a little large so I decided to try using a separate subclass WindowController for the implementation.
I have subclassed NSWindowController. The nib file has myController as the owner. It implements both windowDidLoad and awakeFromNib. It has a TabView and each TabView has several TextFields, a ComboBox, 2 TextViews and a couple of buttons (Cancel and OK). The pointers to the Window, the TabViews, the Cancel and OK buttons are being established but the pointers to the comboBox, TextFields and TextViews are all nil.
The window is becoming visible with all of the TextFields, TextViews and Buttons. The TabView is working to switch views. I can edit all of the TextFields but I cant initialize them or get the info out of them when I dismiss the window.
I am using XCode 3.2 and Objective-C.
What am I missing?
Alan
First, the obvious: Have you checked to make sure these outlets have not become disconnected in your xib? This is a ridiculously common problem, no matter how experienced you are with the tools. :-)
Second, what of the code in -windowDidLoad and -awakeFromNib? You might want to list everything in those two methods that 'touches' the problem outlets. Is it possible you might be assigning them to something else?
I found the answer. It was a namespace issue. I had a setXXXTextField function where the TextField was named XXXTextField. So on attempting to initialize the pointer it called my set function which wasn't designed to set the pointer.
Thanks anyway for the help, it made me look deeper.
Alan