I was trying to use an EKEventEditViewController in my app, which has a global tint (set here:
However, when the app is run, the EKEventEditViewController's navigation buttons are gray, as if they were disabled:
The buttons still work, I just don't want them to be gray like this.
My storyboard:
The popover to present the event edit view controller (it's presented when you click the "Add to my Calendar" button):
The code for presenting the EKEventEditViewController is as follows:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UINavigationController *nav = [self.storyboard instantiateViewControllerWithIdentifier:#"theIdentifier"];
SODPopoverViewController *controller = nav.childViewControllers[0];
controller.startDate = [NSDate dateWithTimeIntervalSinceNow:0];
self.popover = [[UIPopoverController alloc] initWithContentViewController:nav];
self.popover.delegate = self;
[self.popover presentPopoverFromRect:[tableView cellForRowAtIndexPath:indexPath].frame inView:[tableView cellForRowAtIndexPath:indexPath].superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Any idea what's going on?
Miscellaneous information:
I am using iOS 7.1
I am using XCode 5
I am using storyboards
This is not the complete program, just a demo.
SOD stands for Stack Overflow Demo
Thanks in advance!
EDIT: the buttons are gray even without the global tint
I was messing around with the problem a little bit more, and noticed that it wasn't actually the global tint, but the fact that it was being presented modally. This question answered mine: the solution is setting self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
Related
I am converting an iPhone App to an iPad App. I wish to present several of the view controllers as popovers that were previously pushed on the iPhone by changing the segue type in the storyboard from push to popover. The view controllers have a title, a done button, and a cancel button in the navigation bar. Now, when I run the iPad App the popover appears but without the navigation bar. How can I get the navigation bar to show. I have already tried expected setting it not hidden in viewWillAppear which did not work.
I have been able to change the segue to an IBAction with the following code and got it to work. It seems somehow the popover does not have a navigation controller so I created one. `
// Device is iPad
addNoteVC = [self.storyboard instantiateViewControllerWithIdentifier:#"addNoteVC"];
popoverNav = [[UINavigationController alloc] initWithRootViewController:addNoteVC];
[addNoteVC setManagedObjectContext:self.managedObjectContext];
[popoverNav.navigationBar setTintColor:[UIColor darkTextColor]];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor darkTextColor],NSForegroundColorAttributeName,nil];
[popoverNav.navigationBar setTitleTextAttributes:textAttributes];
[addNoteVC setSelectedClient:selectedClient];
[addNoteVC setAddNoteTableViewControllerDelegate:self];
popover = [[UIPopoverController alloc] initWithContentViewController: popoverNav];
[popover setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
popover.delegate = self;
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
`
While the above code works it creates significant differences from the iPhone App code. I would rather that the iPhone and iPad stayed the same as much as possible. If adding a another navigation controller for the popover is the only solution I would prefer to do this in a custom segue so the view controller code can stay the same. In addition that approach would have the economy of one custom segue instead of changes for every view controller presented as a popover. If that indeed is the best solution, details on the custom segue would be appreciated and accepted.
I have a UITabBarController with two UIViewController inside.
How to initilaiser UIViewController not to display a portion is below the UITabBar ?
Edit:
AppDelegate.m:
ViewController *viewController = [[ViewController alloc] init];
self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:#[viewController] animated:YES];
self.window.rootViewController = self.tabController;
ViewController.m:
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview: [[MyGraphicView alloc] initWithFrame:[self.view bounds]]];
}
How to initilaiser UIViewController not to display a portion is below the UITabBar ?
I think you're mistaking the gloss effect for translucency that's allowing the table to show through the tab bar. Here's an image showing two tabs:
It does look like the content view is showing through from under the tab bar, but it's not really showing through -- you're just seeing the glossy effect used to draw the tab items. To illustrate, I'll change the background color of the content to purple:
If the content were really showing through the tab bar, you'd see purple showing instead of the white/gray that you can see is there. To see this in your own app, just scroll the table a bit. If the table were really showing through the tab bar, you would be able to read the content of the next cell, including the "9" and the separator line. I'm sure you won't see that, though.
I read that it is bad to have such structure in an iOS application. But what if an application has a lot of UINavigationControllers and UITabBarControllers. But one UINavigationBar and one UITabBar are always displayed only? Other UINavigationBars and UITabBars are hidden.
EDITED
For example, in navigation-based application I call this code:
- (IBAction)openTabsController:(id)sender {
tabOneController *tabOneViewContr = [[[tabOneController alloc] initWithNibName:#"tabOneController" bundle:nil] autorelease];
UINavigationController *tabOneNavContr = [[UINavigationController alloc] initWithRootViewController:tabOneViewContr];
tabTwoController *tabTwoViewContr = [[[tabTwoController alloc] initWithNibName:#"tabTwoController" bundle:nil] autorelease];
UINavigationController *tabTwoNavContr = [[UINavigationController alloc] initWithRootViewController:tabTwoViewContr];
UITabBarController *tabContr = [[[UITabBarController alloc] init] autorelease];
tabContr.viewControllers = [NSArray arrayWithObjects:tabOneNavContr,tabTwoNavContr, nil];
sel.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:tabContr animated:YES];
}
After calling of this method I have two UINavigationControllers and one UITabBarController. At the same time I have one UINavigationBar and one UITabBar on a screen.
EDITED
Approximate scheme.
From The beginning we have an UINavigationController which allows to navigate between the views (circles). Then after pushing an UITabBar appears and allows to switch between the views. A rectangle with two little rects is a view with a UITabBar with 2 UITabBarItem s. When we presss any UITabBarItem another UIView appears. In this UIView we can press some button which calls another view with another UITabBar. Current UITabBar is visible after pushing if it is not hidden with another UITabBar.
is it more clear now?
The code above works almost perfect (except of some animations and not including Apple's limitations)
Gargo,
I'm not sure I understood your question but the apple documentation is clear. If you use - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated it says that viewController:
cannot be an instance of tab bar controller and it must not already be
on the navigation stack.
Since you do
[self.navigationController pushViewController:tabContr animated:YES];
you are pushing a tab bar controller instance within the navigation stack.
If you add the structure that you would achieve maybe I can help you to find another solution.
Hope that helps.
An app should only have one working tabBarController at any one time.
A tabBarController should also be the root view controller. Always. (If you need a login view or similar before the tabBarController, then remove the login view, create the tabBarController and then make that the root).
This is Apple' advice spoken to me personally by Apple engineers.
Remember, apps should be small applications that are quick and easy to use/navigate. If you feel the need for more than one tabBarController then your app design is likely very wrong from a UI/Usability perspective.
This question already has an answer here:
Creating nib view from UIBarButtonItem?
(1 answer)
Closed 8 years ago.
So I've seen previous questions similar to this but they were of no help. I've read Apple's documentation too but I could not understand where I've gone wrong. AFAIK I did everything logically, but when I click on my done button on an UItoolbar overlay, the button can be pushed but it does not do anything. This obviously means it fails to acknowledge the written code. But how?
I want to bring up the .nib of "TableViewController" when a done button is clicked on my UIToolBar. But the below isn't allowing the click to bring up a new view. How do I rectify this? Please show me where I went wrong and what should be replaced and why.
//Here's the selector:
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemDone target:self action:#selector(doneButtonPressed)];
Here's how I made my action. Btw, the uitoolbar has no nib, it's an overlay on the imagepickercontroller(camera mode).
-(void)doneButtonPressed {
TableViewController *tableView = [[TableViewController alloc]
initWithNibName:#"TableViewController" bundle:nil];
tableView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:tableView animated:YES];
}
//Yet nothing happens when I click on my done button on my overlay. The button can be
clicked nothing happens. Please shed any insight pleasee!
This may not actually be the problem, but if the code your using above is how you're dismissing your Modal view controller it is incorrect. Other than possible improper usage I don't see any problems.
Use what you're using to present the Modal view controller, then to dismiss it use this:
[self dismissModalViewControllerAnimated:YES];
Preface: I am not using *.xib files.
I instantiate a UINavigationController in a class that effectively serves as my 'rootViewController'. This 'rootViewController' also has two UITableViewController members that are drawn on different sections of the iPad screen. One of which is set as the root view for the navigation controller. Let's call it tableViewControllerA.
The problem is, when I invoke pushViewController on a valid UINavigationController, I see no effect:
[tableViewControllerA.navigationController pushViewController:tableViewControllerX animated:YES];
I've gathered from the posts I've searched today, that this push method should in turn cause the screen to redraw the top of stack controller.view. This is not what I'm seeing.
It seemed there was a disconnect in my implementation, and it was time to reference a working example in my environment (xcode 4.0). Assuming the canned templates would provide a working basis, I created a new navigation-based applications. I simply modified didFinishLaunchingWithOptions: as follows.
UIViewController *view1 = [[UIViewController alloc] init];
UIViewController *view2 = [[UIViewController alloc] init];
view1.title = #"view1";
view2.title = #"view2";
[self.navigationController pushViewController:view1 animated:YES];
[self.navigationController pushViewController:view2 animated:YES];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:view1];
[view1 release];
[view2 release];
I found similar results. When I launch the simulator the screen title reads the title of whatever the self.window.rootViewController is pointing at. With the code as is, the title of the resulting top screen reads "view1". When I initWithRootViewController:view2, the resulting top screen reads "view2".
So please tell me I'm stupid cuz xyz...
Thanks.
Here are some references and suggestions:
Simple tutorial for navigation based application:
http://humblecoder.blogspot.com/2009/04/iphone-tutorial-navigation-controller.html
Here is another one to create the step by step navigation controller and adding the views:
http://www.icodeblog.com/2008/08/03/iphone-programming-tutorial-transitioning-between-views/
and here a bit advance with navigation + tab bar controller:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CombiningToolbarandNavigationControllers/CombiningToolbarandNavigationControllers.html
Without seeing your code, I have 2 theories:
Your syntax and calls are wrong when you do the push. Use this as a model:
-(void)Examplemethod {
AnotherClassViewController *viewController = [[[AnotherClassViewController alloc] initWithNibName:#"AnotherClassView" bundle:nil] autorelease];
[self.navigationController pushViewController:viewController animated:YES];
}
You are never adding the navigation controller to the view hierarchy which never adds the view either. Take a look at this.