[Noob question]Opening other view inside window

Discussion in 'iOS Programming' started by Samppaa, May 28, 2010.

  1. Samppaa macrumors regular

    Joined:
    Mar 26, 2010
    #1
    I got a little program with a button that when the user presses it I want it to open another view, the button is "Add note" I want that new view slides from bottom to top so user can add the info and accept it, the same way like you can in address book add new contact. What I got here is a class called Notecontroller and function to open my other view that is linked to it:

    Here is the code

    Notecontroller.h
    Code:
    #import <Foundation/Foundation.h>
    
    @interface Notecontroller : UIViewController {
    
    IBOutlet UITableView * TableView;
    IBOutlet UIView * OpenView;
    
    }
    
    -(IBAction)OpenAddnoteform:(id)sender;
    
    @end
    
    Notecontroller.m

    Code:
    
    #import "Notecontroller.h"
    
    @implementation Notecontroller
    
    -(IBAction)OpenAddnoteform:(id)sender
    {
    //
    //  Notecontroller.m
    //  Muistio
    //
    //  Created by Samuli Lehtonen on 28.5.2010.
    //  Copyright 2010 Test. All rights reserved.
    //
    
    #import "Notecontroller.h"
    
    
    @implementation Notecontroller
    
    -(IBAction)OpenAddnoteform:(id)sender
    {
    [OpenView setFrame:CGRectMake(0, 480, 320, 480)];
    [OpenView setBounds:CGRectMake(0, 0, 320, 480)];
    
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationDelegate:self];
    [OpenView setFrame:CGRectMake(0, 0, 320, 480)];
    [UIView commitAnimations];
    }
    @end
    }
    
    Sorry I am this noob, but I couldn't google even as I don't know the exact words.
     
  2. akira1985 macrumors newbie

    Joined:
    May 28, 2010
    #2
    How about trying to use SDK-friendly solution

    Moi. First, based on your description above, I suppose that instead of customizing and displaying a customized view by yourself, using a more SDK-friendly solution might be recommended in this case. Declare another view controller (ex, MyViewController) in your Notecontroller as a property, and implement necessary methods in MyViewController to handle user input and stuff like that. Here's a sample code snippet you might need:
    Code:
    -(IBAction)OpenAddnoteform:(id)sender
    {
    	[self presentModalViewController:MyViewController animated:YES];
    }
    Then, in the implementation file of your "MyViewController", there should be a button to bring the user back to the previous view (NoteController.view) when user finished his input, implement this:
    Code:
    -(IBAction)handleUserInputEnded{
    //before return to previous view, you should implement codes to handle saving user input and stuff like that, then:
    	[self dismissModalViewControllerAnimated:YES];
    }
    
    I'm not sure if that is exactly what you're looking for, anyway, good luck.
     
  3. Samppaa thread starter macrumors regular

    Joined:
    Mar 26, 2010
    #3
    Got it now, but when I try to put the last action to button that closes the window, my app crashed, I can make the dialog come up, but when I try exit it with my button it crashes :S
     
  4. akira1985 macrumors newbie

    Joined:
    May 28, 2010
    #4
    Well, there could be dozens of reasons that caused the crash, I couldn't pin point any unless you show some code here. So, please.
     

Share This Page