the master detail application included when you use Storyboards this code in view did load.
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(insertNewObject:)];
i want to use this like in same project with .xib'S
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(showGegenstellenView)];
the problem is that i can't implement this code in the storyboard project. I can't find help special for storyboards...
-(void)showGegenstellenView{
GegenstellenViewController *gegenstellenViewController = [[GegenstellenViewController alloc]initWithMasterController:self Gegenstellen:nil];
[self presentModalViewController:gegenstellenViewController animated:YES];
}
Finally I want to click in the table view the add button and a view comes with a formular.
All this works in the project with xib's i have. But i want it with storyboards! I have no problem when u want see the xib project via team viewer or as sib by mail.
Best Regards
John
Related
I have several .xib files (page1, page2 ...) and want to switch between them using buttons (as a navigation bar)
I am using
page1 *second = [[page1 alloc] initWithNibName:nil bundle:nil];
second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:second animated: YES];
page2 *second = [[page2 alloc] initWithNibName:nil bundle:nil];
second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:second animated: YES];
and so on...
I learned that this consumes a lot of memory because I am presenting a view over and over again and after switching back and forth the app sometimes crashes.
So, question is what can I do?
I tried this:
[self dismissModalViewControllerAnimated:YES]
but after dismiss it returns to the previous page and I can not navigate to another one.
Probably I used a stupid approach, however, I've done a few apps that way and don't want to change the controller completely.
Thank you for your help!
I think you have to create IBActions from that 2 blocks of code an link that IBActions to the right button.
I'm sure this was covered before but I can't find exactly what I'm after. I'm using a custom image for the back button on my navigation controller and need to remove the text, is there a simple way of doing this? Thanks.
Try to set the back button as follows:
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"back-arrow.png"]
style:UIBarButtonItemStyleBordered
target:self
action:#selector(backButtonPressed:)];
self.navigationItem.leftBarButtonItem.title = #"";
Ok, it's 3 am atm and I haven't a clue where I put this:
[navigationController.navigationBar setTintColor:[UIColor redColor];
If you would please post the whole .m/.h files that would be great. Also, do I connect anything using segues or outlets? And when you create the .h/.m files do I need UINavigationController or similar selected or just the normal UIViewController? Thanks.
Update: Nevermind I got it, thanks though. Below is the code for others having my issue.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor lightGrayColor]];
}
Basically just add on to what's already there.
I feel stupid lol.
You can set that value right after you init your UINavigationController, i.e:
UINavigationController *controller = [[UINabvigationController alloc] initWithRoot...
[controller.navigationBar setTintColor:[UIColor redColor]];
I'm trying to dismiss any currently visible UIPopoverControllers if/when another UIBarButtonItem is tapped as seen on Pages for the iPad when tapping between Styles/Media/Tools etc.
I've done this, but it's too specific. Looking for something generic.
if ([popoverController isPopoverVisisble]) {
[popoverController dismissPopoverAnimated:YES];
}
Thanks!
Did you set the passthroughViews property of the popover controller? If you do this, then taps outside the popover will not cause the popover to automatically dismiss, but will instead be sent to the views in that array. You should be able to add the UIBarButtonItem to this array, and then dismiss the popover in that handler.
randallmeadows answer will NOT work. UIBarButtonItem is not descendant of UIView, which means you cannot add it to passthroughViews.
The only solution I found for now is to create UIBarButtonItem with custom UIButton using
UIBarButtonItem *b = [[UIBarButtonItem alloc] initWithCustomView:button]
and then
popoverController.passthroughViews = [NSArray arrayWithObject:b.customView];
But be prepared that you'll loose all the styling - you cannot create UIButton that looks like UIBarButtoItem too easily.
[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
popoverController.passthroughViews = #[];
Works for me
A buddy of mine asked for a quick sample of code for an app skeleton that would use a TableView to call a TabView. I estimated an hour.
After more hours than I want to admit messing around in IB, I gave up and implemented the following code.
Can anyone tell me how to do this in IB? I was careful (I thought) to make all the right connections, but no go. I even had another (working) app where I went through and step-by-step made the same connections. I got errors about "Changing the delegate of a tab bar managed by a tab bar controller is not allowed..." (This when I connected the TabBar's delegate to the File's owner, even though another app was working fine with that setting)
Until I wrote this code, I never got the tabbar view, only the view that came with the view xib... (I tested by putting a label on the view).
Thanks in advance...
UITabBarController *tabBarController = [[[UITabBarController alloc] initWithNibName:nil bundle:nil] autorelease];
NumberOneViewController *numberOneViewController = [[[NumberOneViewController alloc] initWithNibName:#"NumberOneViewController" bundle:nil] autorelease];
NumberTwoViewController *numberTwoViewController = [[[NumberTwoViewController alloc] initWithNibName:#"NumberTwoViewController" bundle:nil] autorelease];
NumberThreeViewController *numberThreeViewController = [[[NumberThreeViewController alloc] initWithNibName:#"NumberThreeViewController" bundle:nil] autorelease];
NumberFourViewController *numberFourViewController = [[[NumberFourViewController alloc] initWithNibName:#"NumberFourViewController" bundle:nil] autorelease];
tabBarController.viewControllers = [NSArray arrayWithObjects:numberOneViewController, numberTwoViewController,
numberThreeViewController, numberFourViewController, nil];
[self.navigationController pushViewController:tabBarController animated:YES];
self.view = tabBarController.view; in the viewDidLoad method of the TabBarController delegate class fixed it...
Ah well, surely someone else will run into the same thing and hopefully this will help them...