UIBarButtonItem not responding to touch - objective-c

I don't know what wrong but my UIBarButtonItems in a UIToolBar aren't responding. I have a splitviewcontroller and the bar button item that is implemented with the template isn't responding either. It literally doesn't even change it's tint when click. I created a new UIViewController , presented it as a modal view controller. The vc has a toolbar and a barbuttonitem, and the bar button item is hooked up to an IBAction. That's not responding either. Is there something I am missing here?
Thanks.

Well by default in the viewcontroller.xib should have touch enabled, but just in case you should check the properties inside the viewcontroller of the UIBar and see if buttonpress is enabled or whatever option for interaction is in the xib

Related

Why I cannot add a navigationItem outlet from File Owner to Navigation Item?

I did this in a viewController
self.navigationItem.rightBarButtonItem=self.Share;
And that does it right.
However, I want to do this in xib instead.
I managed to put a Navigation Item item in XIB and I want that to be the navigationItem of the viewController.
Yet I can't do that.
While I can point the "view" outlet from the viewController, I can't point navigationItem
Actually how to add a rightBarButtonItem through XIB?
Who "owns" that rightBarButtonItem anyway? The navigationController or the viewController under it? How exactly does that interact? There is this navigationBar item in object library but I am not really sure how to use it.
You can take a bar button in the coding like IBOutlet UIBarButtonItem * saveButton;
Then you have to take a bar button in the xib file and bind this button with that and in coding you can directly write self.navigationItem.rightBarButtonItem = saveButton;
I am not sure this is correct. Basically I can add navigationItem under the viewController, and viewController.navigationItem automatically point to that navigationItem.
That's it. No outlet is necessary. So it's different than view outlet.
I'll select this as the right answer unless someone told me differently.
Also, having a navigationItem there will prevent the title of the navigation bar to be your viewController title.
You have to do self.navigationItem.title=self.title in viewDidLoad, and I feel that I must have done something wrong here.

Interact with other views while a popover is active

I have a toolBar and I have setup two UIBarButtonItem on it. Both UIBarButtonItem are containing UIButtons as their customViews.
I activate a popover for their Touch Up Inside event as below,
[popover1 presentPopoverFromBarButtonItem:buttonItem1 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
I have another UIButton named clearFilters inside the main view. (Also this is the view which is containing the above toolBar.) I have declared a method for clearFilters button's Touch Up Inside event.
My problem is,
I can not interact with the clearFilters button while a popover is active. So, I'm looking for a solution to interact with this clearFilters button, while a popover is active.
I tried by adding passthroughViews property for a popover as below and it do not work as I expect.
popover1.passthroughViews = [NSArray arrayWithObject:clearFiltersButton];
What could be the reason. As the documentation has mentioned I can not see any issue.
I expect if the above things are correct, then the Touch Up Inside event of the the clearFilters button's should be fire up.
So, please show me if there is any issue or a necessary way to work on this thing.
I'm working on XCode4 and iOS 4.3.
Thanks.
The UIPopoverController documentation reveals why the other bar buttons can be tapped while the popover is visible:
“When presenting the popover, this method adds the toolbar that owns the button to the popover’s list of passthrough views.”
Try querying and logging the popover’s passthrough views. Does it already have things in it? Perhaps something like this would work?
myPopover.passthroughViews = [myPopover.passthroughViews arrayByAddingObject:clearFilters];
I haven’t tested this code, but it’s worth a try.

How to Notify RootViewController of View Changes

I have added a UIButton to a toolbar that is only accessible via the RootViewController (which has a navigation bar and toolbar) of my app. When navigating to another view, I hide the UIButton, but when I go back to the initial screen (a map view) the UIButton remains hidden and I must unhide it. Since it is the RootViewController I am doing this in, viewWillAppear is not called, so I cannot use that method.
I am wondering if there is any way the RootViewController knows when a view is being popped off the navigationController stack, if so, how would you suggest I check for this? Is there any way you would recommend implementing this?
Thanks in advance!
if your app using UINavigationController for navigation then viewWillAppear will obviously called

Keyboard handling on a UIModalPresentationFormSheet presented sheet

I have a UIViewController that is presented with UIModalPresentationFormSheet. So when the keyboard is visible it stays visible until the view controller gets dismissed.
In that UIViewController I have a navigation controller. So in every UIViewController pushed to that navigation controller I have to check these things:
when the keyboard shows/hides I have to adjust the contentInset
when view appears I have to check if the keyboard is visible or not (the navigation controller remembers that with the notification) and adjust the contentInset. I push UITableViewControllers there, so I don't get viewDidAppear and co. So I have to do all this with the UINavigationControllerDelegate methods?
on every rotation I have to do adjust the contentInset
Otherwise the keyboard may cover some content.
Is that the correct handling? Isn't there any easier solution for this problem? Because this is kind a messy!
I didn't found a better solution, so i did it this way.

UISplitViewController - BarButton Item not shown at start

I'm having trouble showing a UISplitViewController programatically.
I have two views, a UIView with buttons which when are pressed load my own custom RootViewController and DetailViewControllers into SplitViewController and then hides the menuSubview for showing UISplitViewController.
Well, it works well in portrait orientation, but when the view is shown the barButtonItem associated with the popOverViewController is not shown. After if I change orientation to landscape, then back to portrait again, the button appears.
Why does this happen? Is there any way to fix it?
I have a little idea. When splitviewController.view is added to the window, the root and detail view controllers are not set yet so could that be the cause?
Well at last I solved the error.
Instead adding two subviews and show/hide them, I add my splitViewController.view as principal to the window and presented the menuViewController as modal, so this issue was solved.