I have a uimenucontroller that I am using on a uiwebview. The menu controller works fine on simple text websites however on larger websites i.e. http://www.foodnetwork.com/recipes/giada-de-laurentiis/grilled-chicken-with-basil-dressing-recipe/index.html my custom menu item will not respond to touches. When tapped it highlights blue briefly then back to black, the menu is still displayed and myAction is nevere called. Sometimes if I click rapidly othe menu controller it will respond so I believe it may be something to do with the responder chain and or the size of the web page. I initialize the menu controller as follows:
// in view did appear:
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:#"Item1" action:#selector(myAction)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:item1]];
-(void)myAction
{
//do something
}
Thank you! I have been stumped by this for 2 weeks and am out of ideas...
Related
I am creating an iOS app that displays a web view. How can I show an animated busy icon that shows a webpage is still loading. The icon should of course disappear when the webpage is fully loaded. An example code would be nice to have.Thanks
OK, I figured out my own problem. For those of you who might want to know how to do this... UIWebView has a protocol called UIWebViewDelegate Protocol naming some methods that can be implemented optionally. To show an animated icon in the status bar while a web page is loading, simply implement the webViewDidStartLoad method. Something like this...
- (void)webViewDidStartLoad:(UIWebView *)webView {
// starting the load, show the activity indicator in the status bar
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
I implemented the following code to show the navigation bar with a backbuttonbaritem.
[mapNavigationItem setTitle:#"Tracking"];
[mapNavigationItem setRightBarButtonItem:nil];
[mapNavigationItem setLeftBarButtonItem:nil];
UIBarButtonItem *stopTrackingBarButton = [[UIBarButtonItem alloc] initWithTitle:#"Stop Tracking" style:UIBarButtonItemStylePlain target:nil action:#selector(stopTracking)];
[mapNavigationItem setBackBarButtonItem:stopTrackingBarButton];
[mapNavigationBar pushNavigationItem:mapNavigationItem animated:NO];
[stopTrackingBarButton release];
The stopTracking button is displayed on the screen, but no title is displayed. When i click on the stopTracking button, it disappears and then shows the title.
Could someone please tell me whats happening??
Ok i think i wasnt clear enough,
I have a mapview with buttons in the tab bar, when the app starts the navigation bar shows 2 buttons, when i click on one of the Tab bar items, it should clear the navigation bar buttons and add a back button bar button item only. I am successful upto this stage.
But when i click on the BackBar button item, it disappears, and does not perform the action assigned to it.
FYI:
IBOutlet UINavigationBar *mapNavigationBar;
IBOutlet UINavigationItem *mapNavigationItem;
If you want to use a different title for your back button than the previous navigation title, then you need to change it just before pushing the new view controller and change it back again after popping it.
So something like:
self.navigationItem.title = #"Stop Tracking";
[self.navigationController pushViewController:mapNavigationItem animated:NO];
and in this class's viewWillAppear
self.navigationItem.title = #"Tracking";
Edit:
If you are not using the backbarbutton for taking the navigation controller back then dont set it as a backBarButton simply set it as left barButton item.
Plus it also seems like you are using same navigation bar for both tabs. not a good idea. Load both tab views from different viewcontrollers and add two different navigation bars to those views.
This relates to a question I asked a few days ago: iOS: Setting text in nib subview from view in UITabBar/UINavigationController application
I need to put the search bar and buttons on the top right of a navigation controller, this is more than the standard single button that UINavigationController.navigationItem.rightBarButtonItem allows so I am using the initWithCustomView: method of UIBarButtonItem to load a view from a nib file.
In my particular case, i've put the view as a seperate item in the main view file for that form
The problem i've got is load and display sequence and I wanted to know if this was the right approach to this?
It seems that the following happens:
viewDidLoad on my main window gets called
viewDidAppear on my main window gets called and I set up rightBarButtonItem
I then want to populate a text field on that search bar but because the loading of the view for the button item happens in the main thread, I don't know when it's appeared.
Would I be better to create a new class with nib for the search bar and buttons which would then have a viewDidLoad/viewDidAppear and I could then create a delegate function so I could 'deQueue' the text to go into the search bar?
Or, am I missing something really simple?
I have been struggling for some time with the strange behavior of navigation bar items. I have segmented control on the navigation bar (take a look at the image below)
where List button pushes table view controller with UISearchDisplayController. To show table view controller I use the code as it follows:
if (uiSegmentedControl.selectedSegmentIndex == 1 )
{
DetailsTableVewController* detailsViewController = [[DetailsTableVewController alloc]
initWithList:list];
[self.navigationController pushViewController:detailsViewController animated:YES];
[detailsViewController release];
}
Then to return back I use the following code:
[self.navigationController popViewControllerAnimated:YES];
Although I use the code above to go back to the previous controller when UISearchDisplayController is either active or inactive I have different behavior of the navigation bar items. When UISearchDisplayController is active ALL items disappear from the navigation bar
Does anybody know why it happens?
Thanks in advance.
Moved all navbar initialization code from viewDidLoad to viewWillAppear in controller and it solved the problem
In my windows based applicaton, after login screen and registration page I added navigation controller for next two views. After pressing button present on second navigation window,again i want normal view controller and not navigation. But Its giving me navigation window with back button which takes me to second navigation window.
Can anyone plz tell me the solution??
You have a couple choices: you can truly eliminate the Navigation Controller entirely and replace it with another UIViewController (more complicated), or you can just push a new UIViewController that will not have a navigation bar/back button, and use that as the effective "root" view controller of your application from there on out. Without the navigation bar, your view controller will look like a "normal" view controller.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.hidden = YES;
...
}