Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:08:24+00:00 2026-05-25T19:08:24+00:00

I have a modal view controller which is used in several places throughout my

  • 0

I have a modal view controller which is used in several places throughout my app and, in an attempt to apply to ‘DRY’ as much as possible, want to encapsulate the oft repeated task of creative a UINavigationController and dropping the view controller inside of it.

Essentially I’m trying to replicate what Apple do with MFMailComposeViewController. You can simply init this object and present it modally and it handles the UINavigationController creation for you.

I tried to emulate this by creating a sub class of UINavigationController (as MFMailComposeViewController does), then put a custom init method in that creates a view controller, calls [super initWithViewController:] and proposes itself as the VC. This fails because initWithViewController: in turn calls the init method and we enter a recursive loop.

Is it possible to write a custom class that behaves the same way MFMailComposeViewController does and create my own init method that still allows UINavigationController to call the init method it expects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:08:25+00:00Added an answer on May 25, 2026 at 7:08 pm

    You should not try to push yourself on your own navigation stack. Your navigation controller subclass should create a separate view controller in its init method that will be the navigation stack’s root view controller.

    The documentation for initWithRootViewController: says:

    This is a convenience method for initializing the receiver and pushing a root view controller onto the navigation stack. Every navigation stack must have at least one view controller to act as the root.

    So I suppose you can just call [super init] in your init method and then call [self pushViewController:myRootController] directly afterwards. You must also override initWithRootViewController: and make sure it calls your init method, ignoring its argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two View Controllers: TableViewController (which is used as a modal view controller)
I am trying to present a modal view controller. I have read the documentation,
I have a controller action which passes a list of products to the view.
I need some help with modal view controllers, as I have not used Modal
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
I am having trouble getting my modal view controllers to display properly. I have
I have a Java project that I'm trying to implement with a model-view-controller design.
I have a model, view and controller not interacting correctly, and I do not
I have a view model with a property Fields which is an ObservableCollection<FieldVM> .
I have a UITableView (on a navigation controller stack) which is showing details for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.