Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-14-2010, 08:52 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: Québec
Posts: 21
Default UIAlertView clickedButtonAtIndex with presentModalViewController

Hi,

I am trying to call a view via presentModalViewController from a UIAlertView button. The code is below, the NSlog is displayed in the console so I know that code execution is indeed reaching that point. Also, there are no errors or anything displayed:

Code:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

if (buttonIndex != [alertView cancelButtonIndex])
{
    NSLog(@" The username is: %@ AND the password is: %@ ",textField.text,passTextField.text);

 // do some logic in here later 

    CompanyViewController *companyViewController = [[[CompanyViewController alloc] initWithNibName:@"CompanyViewController" bundle:nil] autorelease];  
    [self presentModalViewController:companyViewController animated:YES];
}
[textField resignFirstResponder];
[passTextField resignFirstResponder];

}
The method above belongs to a UIViewController. Below is the interface file:
Code:
@interface testingViewController : UIViewController  <UITextFieldDelegate>
{
UITextField *textField;
UITextField *passTextField;
}
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) UITextField *passTextField;
@property (readonly) NSString *enteredText;
@property (readonly) NSString *enteredPassword;

@end
Any suggestions would be appreciated. Thanks for your time.
howcr is offline   Reply With Quote
Old 03-14-2010, 09:02 PM   #2 (permalink)
Will Work for Food!
 
itzdark's Avatar
 
Join Date: Apr 2009
Posts: 579
Send a message via AIM to itzdark Send a message via MSN to itzdark
Default

Code:
[self.view presentModalViewController:companyViewController animated:YES];
__________________

Check out my apps

Developers, check out study buddy. I use it everytime I code. It's great for those late night coding sessions.
Unofficial Ad Hoc Distribution Guide || Join my cooperative ad hoc testing group
iSoothe Promotional Video
Contact Me
itzdark is offline   Reply With Quote
Old 03-14-2010, 09:18 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: Québec
Posts: 21
Default

Hi,

I'm getting a warning: UIView may not respond to 'presentModalViewController:animated:'
howcr is offline   Reply With Quote
Old 03-15-2010, 11:30 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: Québec
Posts: 21
Default

The presentModalViewController is an instance method of UIViewController.

So, since the I am using a UIViewController, the problem is probably with the UIAlertVIew clickedButtonAtIndex method.

I haven't found anything that says you cannot use presentModalViewController from an UIAlertView. Has anyone come across this before?

The reason why I am using the alertview is because I have a button on my apps menu screen that requires a user to login in order to open (like a portal page). So, after I have a successful login I allow the user to view the restricted screen.
howcr is offline   Reply With Quote
Old 03-16-2010, 11:48 AM   #5 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,578
Default

I had a similar problem that was solved by waiting to present the view. So you would replace that line with:

Code:
[self performSelector:@selector(showCompany) withObject:nil afterDelay:0.0];
And put your present view line in a separate function:

Code:
- (void) showCompany {
    CompanyViewController *companyViewController = [[[CompanyViewController alloc] initWithNibName:@"CompanyViewController" bundle:nil] autorelease];  
    [self presentModalViewController:companyViewController animated:YES];
JasonR is online now   Reply With Quote
Reply

Bookmarks

Tags
iphone, uialertview, viewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 270
20 members and 250 guests
ADY, Bertrand21, Dani77, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, jimbo, macquitzon216, MACralik, mer10, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84, Sunny46
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:01 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0