2531

presentModalViewController not responding

Question:

I have 3 classes.

First controllor is the first controllor in tabbar. I am using presentModalViewController to present a login screen and a Home screen. I have a presentModalViewController in firstcontrollor which present the login screen and in Loginscreen viewdidload method I have presentModalViewController which present home screen. The home screen presentModalViewController is dismissed in homePage_Btn_Clicked and presentModalViewController is dismissed in login_Btn_Clicked. The problem I have is my home screen is never presented. Any help? I am new in iPhone development.

//First Controllor

FirstControllor.m

- (void)viewDidLoad { [super viewDidLoad]; Accounts_Login *lvc = [[Accounts_Login alloc]initWithNibName:@"Accounts_Login" bundle:[NSBundle mainBundle]]; [self presentModalViewController:lvc animated:NO]; [lvc release]; } //Login_view class

Login_view.m

- (void)viewDidLoad { [super viewDidLoad]; Home_Screen *lvc1 = [[Home_Screen alloc]initWithNibName:@"Home_Screen" bundle:[NSBundle mainBundle]]; [self presentModalViewController:lvc1 animated:NO]; [lvc1 release]; user_ID_TextField.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"User ID"]; } -(IBAction) login_Btn_Clicked{ if ([services authenticate:credential_Data]) { [self dismissModalViewControllerAnimated:YES]; [credential_Data autorelease]; } //HomePage class

HomePage.m

-(IBAction) homePage_Btn_Clicked:(id) sender{ UIButton *theButton = (UIButton *)sender; int count; switch (theButton.tag) { case 101: count++; [self dismissModalViewControllerAnimated:YES]; break; default: break; } }

Answer1:

Try this:

Home_Screen *lvc1 = [[Home_Screen alloc]initWithNibName:@"Home_Screen" bundle:[NSBundle mainBundle]]; [self.parentViewController presentModalViewController:lvc1 animated:NO]; [lvc1 release];

Answer2:

Move presentModalView from viewDidLoad to viewDidAppear.

Recommend

  • OpenCover testing tool usage in Visual Studio 2013
  • Visual Studio - Can I debug my app on a CE device over the network
  • OpenGL ES Pixel Art - Scaling
  • XCode 9 unknown error -1 = fffffffffff command/bin/sh failed with exit code 1
  • insert view in front of UIImagePickerController
  • how to use a FOR loop variable to help define another variable
  • Unable to Get CakePHP Cookbook Simple ACL Example Working
  • Using 'end' as column name in Ruby on Rails (MySQL)
  • iOS 8 Swift : How to keep the keyboard displayed when the UIAlercontroller is presented modally?
  • How to make swipe on horizontal recyclerview bring only the next item into view - Android
  • android application arabic support
  • PHP: I get a completely blank page, I don't know how to debug this in PHP
  • How can i calculate total positive ,total negative price and sum using Node.js and Mongoose
  • How can I get rid of dynamic SQL
  • Can you actually link constraints to utterly different view controllers?
  • How to push ViewController with slide effect from left to right? Animation name required
  • Set UITableView BackgroundColor Universally with UIAppearance
  • View Controller Loads Twice - How Do I Fix It?
  • UIBarButtonItem - Argument of '#selector' cannot refer to local function - Swift 3
  • updatesearchresultsforsearchcontroller not called
  • Pie-in-pie (Donut) charts
  • windowScriptObject method not found on Objective-C code
  • Printing input from TextField to a Label in Xcode with Swift
  • How do I use SFSafariViewController with a dark theme like this user?
  • Plotting A Hyperboloid
  • Unable to set a breakpoint on main while debugging a program compiled with Rust 1.10 with GDB
  • Why does Sencha 2 only work in Webkit browsers?
  • retrieving data from url in iphone
  • Access user's phone number on iOS 7
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • how to avoid repetitive constructor in children
  • Exchange data b/w iOS devices using Bluetooth 4.0
  • Deleting and Updating values from a cusrsor adapter
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?