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 04-04-2009, 03:08 PM   #1 (permalink)
New Member
 
Join Date: Feb 2009
Posts: 79
Default I can't figure out presentModalViewController

I'm simply trying to get code that creates a slide up view using presentModalViewController and I haven't been able to get it to work at all. I currently have this:

TestAppDelegate.h
Code:
#import <UIKit/UIKit.h>

@class TestViewController;
@class SlideUpViewController;

@interface TestAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    TestViewController *viewController;
	SlideUpViewController *slideUpViewController;
}

- (IBAction)aboutShow:(id)sender;

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TestViewController *viewController;
@property (nonatomic, retain) IBOutlet SlideUpViewController *slideUpViewController;

@end
TestAppDelegate.m
Code:
#import "TestAppDelegate.h"
#import "TestViewController.h"
#import "SlideUpViewController.h"

@implementation TestAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize slideUpViewController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    
    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}

- (IBAction)aboutShow:(id)sender {
	slideUpViewController = [[SlideUpViewController alloc] initWithTitle:@"SlideUpViewController"];
	[self.slideUpViewController presentModalViewController:slideUpViewController animated:YES];	
}

- (void)dealloc {
    [viewController release];
	[slideUpViewController release];
    [window release];
    [super dealloc];
}


@end
I also have a UIViewController class file with the name SlideUpViewController.h/.m with code that just simply shows an alert box when the view is loaded to see if it is loading. That alert is not showing up. I also have a SlideUpViewController.xib file...
__________________
Josh Holat Software
Check out my software at http://www.joshholat.com/iphoneapps.php
joshholat is offline   Reply With Quote
Old 04-04-2009, 03:11 PM   #2 (permalink)
New Member
 
Join Date: Feb 2009
Posts: 79
Default

I should also note that I have a button on the TestViewController file that I am using to execute the aboutShow code. Could that fact that that button is on a separate view controller be the issue? It is in that TestViewController class but calls aboutShow from the TestAppDelegate files
__________________
Josh Holat Software
Check out my software at http://www.joshholat.com/iphoneapps.php
joshholat is offline   Reply With Quote
Old 04-04-2009, 11:50 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default

Quote:
Originally Posted by joshholat View Post
I should also note that I have a button on the TestViewController file that I am using to execute the aboutShow code. Could that fact that that button is on a separate view controller be the issue? It is in that TestViewController class but calls aboutShow from the TestAppDelegate files
Have you placed a view controller in your mainWindow.xib file with it's owner being your slide up view controller? You also have to drag the outlet of your appDelegate object in Interface Builder to your view controller. If you haven't done that, that code will never work.
brian515 is offline   Reply With Quote
Old 04-04-2009, 11:59 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 109
Default

I forgot to mention that this:
Code:
slideUpViewController = [[SlideUpViewController alloc] initWithTitle:@"SlideUpViewController"];
	[self.slideUpViewController presentModalViewController:slideUpViewController animated:YES];
should become this:
Code:
[viewController.view presentModalViewController:slideUpViewController animated:YES];
The object that you will be performing the presentModalViewController on (I'm assuming) is not the slideUpViewController because I don't think that you want to present the slideUpViewController on top of itself in a modalView. Instead, I am assuming that you want the slideUpViewController to appear on top of the viewController. Also, there is no need to allocate another slideUpViewController instance.

Also, how are you building this application? Are there different view.xib files for every view, or is everything in the mainWindow.xib? Sometimes, I find that it is easier, at least with modalViewControllers, just to create the instance of the view you want to "slide up" inside the view.xib file of the view that will be presenting the modalViewController, bypassing the appDelegate entirely.
brian515 is offline   Reply With Quote
Old 04-05-2009, 12:29 AM   #5 (permalink)
New Member
 
Join Date: Feb 2009
Posts: 79
Default

Quote:
Originally Posted by brian515 View Post
I forgot to mention that this:
Code:
slideUpViewController = [[SlideUpViewController alloc] initWithTitle:@"SlideUpViewController"];
	[self.slideUpViewController presentModalViewController:slideUpViewController animated:YES];
should become this:
Code:
[viewController.view presentModalViewController:slideUpViewController animated:YES];
The object that you will be performing the presentModalViewController on (I'm assuming) is not the slideUpViewController because I don't think that you want to present the slideUpViewController on top of itself in a modalView. Instead, I am assuming that you want the slideUpViewController to appear on top of the viewController. Also, there is no need to allocate another slideUpViewController instance.

Also, how are you building this application? Are there different view.xib files for every view, or is everything in the mainWindow.xib? Sometimes, I find that it is easier, at least with modalViewControllers, just to create the instance of the view you want to "slide up" inside the view.xib file of the view that will be presenting the modalViewController, bypassing the appDelegate entirely.
Thanks for the help, you were correct in assuming that. Currently I have three separate .xib files, MainView, SlideUpViewController, and TestViewController. MainView loads TestViewController on startup, and I want the SlideUpViewController to slide up over that one.

The only issue I have now is that I don't know what to connect to what. The App Delegate won't drag on to anything relating to SlideUpViewController...

Is there an easier way to do this where I can just create a button on any view and have it slide up another view no matter what view it is currently on (I think this is what you meant by bypassing appdelegate?)
__________________
Josh Holat Software
Check out my software at http://www.joshholat.com/iphoneapps.php
joshholat is offline   Reply With Quote
Reply

Bookmarks

Tags
modalviewcontroller, 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, AragornSG, Bertrand21, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, iDifferent, JasonR, macquitzon216, mer10, prchn4christ, Rudy, sacha1996, sneaky, spiderguy84, Sunny46, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
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:11 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0