I want to implement the following type of UI flow in my project
http://imgur.com/77pK3
So, basically the following option, I have to show in popover, and on the basis of user selection, I have to navigate to next view, and then can come back to my main view.
My approach so far is in my main view, i m creating a popover with a navigation controller. The navigation controller root view controller is a subclass of UITableView controller. In UITableView Controller, I am presenting the following two options, and when user selects the "Photo Roll" in table view delagate tableVIewDidSelectROw, I am pushing like this
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init]]
impgPicker.source = // source type to camera roll
[self.navigationController pushViewController:imgPicker animation:YES]
but after this line I am getting the crash, I even tried using
[self prsentViewController]
but same result.
Any help will be greatly appreciated, and I am running on iOS 5 simulator.
UIImagePickerController is meant to be used as a modal view controller and displayed using the presentModalViewController:animated: method.
You will likely need to define your own view controllers to implement the interface as designed. You can get access to the albums and photos through the ALAssetsLibrary class.
Related
For some reason, when I try to open a view controller via modal segue, it opens up two of the same type. Why is this happening?
Warning: Attempt to present <ModalViewController: 0x7fa062c5edd0>
on <HomeViewController: 0x7fa062e16e40> which is already presenting
<ModalViewController: 0x7fa062fb9780>
This is causing problems because I try to use delegates, but my main view controller never gets the correct delegate.
The issue occurs when I click the the button which triggers showModalView
HomeViewController
- (IBAction)showModalView:(UIButton *)sender {
ModalViewController *modalView = [[ModalViewController alloc] init];
[self presentViewController:modalView animated:YES completion:nil];
}
I tried this solution here and here and a dozen other ones, but none seem to work for me.
Why is this happening?
The problem you're having, is because you've connected a segue to the button, and are also presenting the controller in code; you should be doing one or the other. When you removed the segue, you got a black screen because you're using alloc init to create your controller. If you made the controller in a storyboard, then you should use instantiateViewControllerWithIdentifier: instead.
However, the easier way would be to leave the segue connected to the button, and delete the code you have in the button's action method. The button doesn't need an action method, if you have it hooked directly to a segue. All of this is covered in Apple's document, "View Controller Programming Guide for iOS". You should read it.
I am interested in creating an app that starts with a menu which may possibly contain an options view, then steps from the menu view to a data-item selection view, then to a configuration view, and finally a result view that displays progress or changes. I want to have this process be repeatable like a loop, and have the user be able to jump backwards to a previous view if necessary. Jumping from view to view would of course be a user input / output with a button or something. FYI, I am using Xcode 5.1.1.
What would be the best approach to this? What kind of view controller is going to do the trick? I have heard a lot about navigation controllers, tables, etc.. but am having a hard time figuring out what to use in my case.
Below is a state-diagram similar to what I would like to do...
A UINavigationController should work great as your root view controller. It automatically includes a back button, and you can use the popToRootViewController method to return to the root of the navigation controller. You can set up a navigation controller as your root view controller from the applicationDidFinishLaunching method using this code.
MainMenuViewController *mainMenuViewController = [[MainMenuViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mainMenuViewController;
self.window.rootViewController = navController;
For more information take a look at apples UINavigationController programming guide https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html
Each of your other screens may use different types of view controllers depending on their specific needs. If you need to display a list of items, definitely look into a UITableView. Apple's documentation for a UITableViewController can be found here https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewController_Class/Reference/Reference.html
I am writing an iPhone application where I want to utilize the large popup view, but I don't know what it's called. I have a picure on it.
I mean the middle square that isn't shadowed. It has the title "Köp mer utrymme". I know it's from an iPad, but I'm pretty sure a similiar one exists on the iPhone, for example, the iTunes-store agreements. I looked in Apple's UIKit User Interface Catalog, but I couldn't found it there.
Does anyone know what it's called or how to get it?
On iPad it could be a UIPopoverController with a custom view controller inside it, or a modally presented view controller. You can't use that on iPhone (at least not in the same way, popovers don't exist and modal views are full screen).
On iPhone you could use a UIAlertView, or you could search github / cocoacontrols for a suitable 3rd party implementation.
The view on the picture is presented modally. When presenting a view modally, you can customize the presentstion style. The default style is UIModalPresentationFullscreen, but the style in the picture is UIModalPresentationFormSheet.
To present a view controller in that style, you first create an instance of the view controller and then set its style.
MyViewController *vc = [[MyViewController alloc] init];
vc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:vc animated:YES completion:nil];
Note that isn't possible to change the presentation style for iPhone. (I must have imagined that the iTunes-store agreement wasn't fullscreen.)
Use KGModal.h and KGModal.m class. For a PopVieController is is best ....and easy to make and add control over it and no need to set frame for orientation ....
Find these 2 Class (KGModal.h and KGModal.m)...
and how do you create it? - the popup one in the middle
I would lie to use something like this for my game (in the main menu).
There is no type for UIViewController. There are different ways how you can present UIViewController.
iPad support following three type:
Full Screen
Page Sheet
From Sheet
Your image is showing third one UIModalPresentationFormSheet.
You can Find detail of how to use this three type of presentation at following app guide:
Presenting View Controllers from Other View Controllers.
That's the link to the documentation.
Presenting View Controllers from Other View Controllers
A modal view controller is a controller that can be presented on top of another one.
To create it, for example, you can just call presentViewController:animated:completion: method of the current view controller, passing in the view controller you want to present.
Since the interface you have uploaded contains a navigation bar that contains a close bar button item, you can simply wrap the controller you want to present in a navigation controller.
YourViewController *yourViewController = [[YourViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:yourViewController];
[self presentViewController:navigationController animated:YES completion: nil];
Otherwise, you can create a plain controller and use a UIToolBar.
Hope that helps.
P.S. The close button will not be there for free. You need to add it ;)
I think it would be much better to use a third party library instead of implementing it. There are many libraries that offer similar functionality.
UAModalPanel
MTPopupWindow
KGModal
If you do not want to use the above libraries, you can use UIModalPresentationFormSheet explained by Apple in this document: Presenting View Controllers from Other View Controllers
Hope this helps!
So i am creating an ipad recipe based app using storyboards. Just to give you an idea of the structure of my program here is the flow of View controllers:
ViewController --Modally--> PreviewViewController --Modally-->
RecipeViewController --Popup--> IngredientsViewController
All of this has been done in storyboarding. I created the IngredientsViewController and have linked it up to the RecipeViewController to be displayed as a popup, which works fine. However i want to be able to dismiss the IngredientsViewController programatically (because i've implemented voice command features). The problem is i can't seem to access the IngredientsViewController to dismiss it. (appologies i can't yet post any pictures).
I am using the following code to present the IngredientsViewController programatically (from within RecipeViewController):
[self performSegueWithIdentifier:#"ingr" sender:nil];
Which works fine to display the popup, but i cant dismiss it. I've tried to access it through the hierarchy of view controllers but cannot seem to find it, i would assume that it would be at the top of the stack, but apparently not? I've tried things like:
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
Again this was called from within RecipeViewController. But that simply dismisses the RecipeViewController and not the IngredientsViewController that is being presented by popup.
Just to be clear the IngredientsViewController is not a UIPopoverController, it is a normal viewController created in storyboard, and its segue style is popup linked to a button in the RecipeViewController.
Any help would be greatly appreciated. Thanks!
UIPopoverController *popOver = (UIPopoverController *)self.presentedViewController;
[popOver dismissPopoverAnimated:YES];
This should do the trick if your destination view controller is a UIPopoverController
Have you tried presentViewController:animated:completion: instead of performSegueWithIdentifier:?