How do you get the UIBarButtonItem that pops out the main menu (when in portrait mode) of the DetailViewController when dealing with a master/detail split view controller? I want to change the title of that button and enable/disable it based on certain actions.
I tried:
self.navigationController.navigationBar.items...
But it doesn't get it for me.
Try: self.navigationItem.leftBarButtonItem
Related
Moving my app from iOS6.1 to iOS7, all the button that were visible under iOS6.1 in the toolbar I created for the Input Accessory View of the keyboard are not visible anymore (but still active).
I tried all combinations of [myBar setTranslucent:...] and [myBar setBarStyle:...] but no way to make these buttons visible again. They are defined as:
UIBarButtonItem *myButton =[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"myImage.png"] style:UIBarButtonItemStylePlain target:self action:#selector(mySelector:)];
<-iOS 7.1
<-iOS 6.1
Any idea? Thanks!
I found the solution of my problem.
The method I used to remove the standard input accessory view of the uiwebview was the reason of this problem, it left some view displayed that prevented from seeing the new UIToolbar view. I used the one described here in Stackoverflow and it works.
This may be a silly question, but how would I go about changing the 'back' button of the navigation controller to simply say 'Back' every time I push to a different ViewController?
For example, if I'm going from the Master to the Detail then it will have: "< Master" as the back button text. Can I change it easily to "< Back" without messing around too much? (It's just I have quite a few segues going and if I have to replace the button manually I'm probably going to screw up something else...)
All help is appreciated. Thanks :)
You need to assign a backBarButtonItem to the current navigation item before pushing another. Navigation items are pushed when view controllers are pushed.
So something like this:
self.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(#"Back", #"") style:UIBarButtonItemStylePlain target:nil action:NULL];
[self.navigationController pushViewController:next];
The target and action of the bar button item are not required, as only the title is used.
You can set backBarButtonItem once in viewDidLoad of your view controller.
It automatically grabs the title of the previous view controller as long as the title is short enough to fit into the button. To override this behavior, you can provide your own UIBarButtonItem for the backBarButtonItem property. (Just create a basic push button and it should work IIRC.)
I want to place a UIView that will inform the user what is the status of the app. I want that view to be visible even if the user switches views, same thing as the UINavigationBar is always visible, but I don't want to use that bar, I would like to add another view that will show a message.
How can this be done? I can't add the view to the current view, because it will disappear, if the user changes views.
It should be added to the window? But how? I would then have to resize the views so that my new view can fit, but how?
Thanks.
Create a container view controller and set it as the rootViewController of the apps window.
Inside this container you have your status view, and you also resize the windows real rootViewController to take up the remaining space as a subview. If you are using a standard container view conrtoller (tab, navigation etc) as the root then you can use standard navigation methods and the status view will always be visible
There would be problems if you wanted to present modal views though, since these would go over the top of the status view
In your appDelegate.m add your view as subView of window.
UIView *mainBg = [[UIView alloc] init];
mainBg.frame = newframe;
[self.window addSubview:mainBg];
If you have a UINavigationController you can add your view to its view.
[self.navigationController.view addSubView:yourView];
Presenting modal views would cover the view, as stated in the other answer.
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.
I'm trying to set up a popover to appear that displays a UIDatePicker when I press a button, however I'm getting some very confusing behavior. I created a view controller that housed nothing but the UIDatePicker, wired one up in the class i needed it in, and added it to a new UIPopoverController like this:
self.timePickerPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.timePickerViewController];
then I present it like so:
[timePickerPopoverController presentPopoverFromRect:prepTimeButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
(prepTimeButton being the button that was pressed). However, I just get the following result:
Instead of it displaying next to the button that was pressed and at the target size (it's way too tall right now; should only be the size of the date picker). I also tried giving it a custom view of the proper location and size in which to display, but that didn't help much (just shifted the popover to the right half of the screen). What am I doing wrong and how do I fix it?
Is self.view the direct superview of prepTimeButton? Perhaps prepTimeButton is nested in a subview, in that case you'd need to use that as the inView: parameter (or convert the coordinates).
Did you set the contentSizeForViewInPopover property of your view controller?
Make sure to set both contentSizeForViewInPopover on the internal view controller and popoverContentSize on the UIPopoverController itself.