Button action event

Discussion in 'iOS Programming' started by sagarshivam, Jun 28, 2011.

  1. sagarshivam, Jun 28, 2011
    Last edited by a moderator: Jun 29, 2011

    sagarshivam macrumors member

    Joined:
    May 24, 2011
    #1
    Dear All!

    In my very first iPhone App< i am trying to create one button(through code and not using IB) and then clicking that button, will read some file (file name is hard coded in the program) from local machine and will display the content on the iPhone.

    I created button as:
    Code:
    - (void)loadView
    {
    	UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    	self.view = contentView;
    	
    	contentView.backgroundColor = [UIColor whiteColor];
    	contentView.multipleTouchEnabled= TRUE;
        [contentView release];
    	
    	// Add an action button
    	self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
    											   initWithTitle:@"Browse" 
    											   style:UIBarButtonItemStylePlain 
    											   target:self 
    											   action:@selector(presentSheet)] autorelease];
    
    }
    
    where "presentsheet" is a function that will include file opening and reading code.

    Am I doing right? How to proceed in "presentsheet"?

    Thnx in advance
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    Why are u creating a new UIView pointer?
    Ah well, for just your question. You just call an function, which you don't show. on a UIBarButtonItem.
    And how to proceed in your function? well, depends, you can show a new controller there, add a subview from your file, parse it and do something with it, limitless stuff to do with it.
    As long we don't know what u want, and show us that piece of code, we cannot help u i must say.
     

Share This Page