简体   繁体   中英

Create Own View Controller I can present modally

I want to create an object that I can present modal view, like UIImagePickerController. With UIImagePickerController I create the object, configure it, then present it modally. like:

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    //Configure the UIImagePickerController
    imagePicker.sourceType        =   UIImagePickerControllerSourceTypeCamera;
    imagePicker.mediaTypes        =   [[NSArray alloc] initWithObjects: @"public.movie", nil];
    imagePicker.videoQuality      =   UIImagePickerControllerQualityTypeMedium;
    imagePicker.cameraDevice      =   UIImagePickerControllerCameraDeviceRear;
    imagePicker.cameraCaptureMode =   UIImagePickerControllerCameraCaptureModeVideo;
    imagePicker.delegate          =   self;
    imagePicker.allowsEditing     =   YES;
    //Present the Controller 
    [self presentModalViewController:imagePicker animated:YES];

I want to do the same thing. I want to have a controller I can instantiate, configure, then present it. I am confused on how to proceed with that though. Do I use a standard UIViewControler (looking into UIImagePickerController header I see apple uses UINavigationController)? How do I connect a view to this controller? Is it a story board or just a xib file. I want to build my controller this way because object can be useful to reuse in other projects so I would love to just be able to send it to the other project with documentation on how to configure it and they can just plug it in and it works (basic object orientation). Are there any basic guides on how to do this?

Thank you for reading and the help.

A good place to start with understanding how to do this would be to see Apple's View Controller Programming Guide for iOS. It gives some good examples and different options on how you could get this accomplished.

Also, have you done/found any simple tutorials that show the process of building a simple application?

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM