I have iPad application with main view controller with a navigation bar at the top. I want to create a signIn button on navigation bar, which should open a popupview with username, password, one additional field and a login button. Clicking login button will close the popover and pass the information from text field back to main view controller.
I have been trying to find something like this on web , but no luck.
Does anyone knows a way to do this ?
You should take a look at UIPopoverController
This is how you initialize and show it:
UIPopoverController *myPopover = [[UIPopoverController alloc] initWithContentViewController:myForm];
[myPopover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionsAny animated:YES];
To get data back from myForm you probably want to use delegation.
myForm.delegate = self; //before presenting de popover
Related
So I tried everything with showing up the back button but it just won't work
This is how i arrange my View Controllers Used segue show from view controller to site view controller
And here is the site view controller that isn't showing back button
I even tried adding NavigationBar and a button with this function
self.navigationController.popToRootViewControllerAnimated(true)
Also failed
Update:
I tried this in both view controllers it's returning nil
in viewDidAppear and viewWillAppear
print(self.navigationController?.restorationIdentifier)
Once I got the same problem, when I was try to use view property of my UIViewController before it loaded properly. This caused problems with loading my navigation bar items. In fact, you should not touch view property until viewDidLoad method is called. Check, maybe it is your case, maybe you use view property in prepareForSegue method or in observers?
My root view controller is an UISplitViewController, which has a UITableViewController as master view controller. On iPhone (compact width), it looks like a UINavigationController.
Tap a cell to show detail view controller
Tapping the trash button would delete the current note. My problem is how to go back to the master view after that? Since it's an UISplitViewController, it can't pop the current view controller as UINavigationController does.
I had a similar problem and finally found a solution. As I understand it, when in compact width, the detail navigation controller becomes a view controller of the master navigation controller. So all you have to do is:
Determine if only one view is present by checking the split view controller's collapsed property. If it isn't collapsed (e.g. on iPad), you're already showing the table view in addition to the detail view.
If it is collapsed (e.g. on iPhone) get a reference to the master navigation controller via the detail navigation controller and have it pop to its root view controller which, in this case the your table view controller.
This is the code I use in my detail view controller. In your case I think you just need to add this code to the button action in your detail view controller:
if splitViewController!.collapsed {
let detailNavController = parentViewController as UINavigationController!
let masterNavController = detailNavController.parentViewController as UINavigationController!
masterNavController.popToRootViewControllerAnimated(true)
}
Good luck!
I have created an app which in total has 4 view controllers. 2 of these are pages that contain content with an (i) button in the top corner which links to an "about" section of the app. Currently I have 2 separate view controllers displaying the same thing (the about page) as I can't get the two view controllers to link to a single one when I click the button on each respectively.
Is there a way for two view controllers to access one view controller without me having to create a different about page for each one?
Thanks heaps
First you should set the button's target:
exampleButton addTarget:self action:#selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside;
Then, in the button's method:
-(void)buttonAction:(id)sender
{
AboutViewController *aboutViewController = [[AboutViewController alloc] init];
[self.navigationController pushViewController:aboutViewController animated:YES];
}
Don't forget to add the about view controller's header file
#import "AboutViewController.h"
If you use storyboard, you should change the button's action method with
-(void)buttonAction:(id)sender
{
[self.navigationController performSegueWithIdentifier:#"aboutSegueIdentifier" sender:sender];
}
Im going to a new view using the following code:
UIStoryboard *storyboard = self.storyboard;
finishViewController *finished = [storyboard instantiateViewControllerWithIdentifier:#"finishViewController"];
[self presentViewController:finished animated:NO completion:nil];
Once the new view is loaded the previous view controller is still functioning behind it. Is there a way I can erase it from memory?
Ive tried:
[self.presentingViewController dismissModalViewControllerAnimated:YES];
and
[self.parentViewController dismissModalViewControllerAnimated:YES];
I thought this would be pretty straight forward. T
Thanks
You're presenting a modal view from the parent view controller.
It sounds like what you really want to do is push or segue the finished view controller from the parent view controller.
If you are determined to dismiss / erase the parent view controller, why not first pop the parent view controller and then push/present the finished view controller.
Try using [finished makeKeyAndVisible] it'll make your new controller the only controller.
This can't be done. If you dismiss the parent you'll dismiss both of them.
This seems like it would be an easy thing to do but I am having a lot of trouble getting a button to respond to events while in a CPTableView. Here is the initialization code:
//deleteColumn is hooked up to CIB table column.
[deleteColumn setEditable:YES];
[deleteColumn setWidth:24];
var deleteButton = [[CPButton alloc] initWithFrame:CGRectMakeZero()];
[deleteButton setTarget:self];
[deleteButton setAction:#selector(deleteClicked:)];
[deleteColumn setDataView:deleteButton];
I then have this selector code in the same view controller:
- (void)deleteClicked:(id)sender
{
console.log(sender);
}
It seems the table view is squashing any mouse clicks inside it because I don't get the console log when I click the button.
Is there an easy way to do this? All I want is a button that deletes corresponding row in the table.
The CPTableView takes over the action of the button for its own purposes. Try listening for the regular edit delegate message CPTableViewDataSource:tableView:setObjectValue:forTableColumn:row: in your table delegate.