Button action event

Joined
Jun 3, 2011
Messages
54
Reaction score
0
Points
6
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:

- (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:mad:"Browse"
style:UIBarButtonItemStylePlain
target:self
action:mad: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
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
First, use the CODE tag around code that you post. It will keep formatting as intended and not post messed up characters such at that sad face.

I haven't created a UIViewController manually before, but looking over your code and some documentation, your code looks fine to me.

I'm not sure what your really asking.

Perhaps you should read "Alerts, Action Sheets, and Modal Views" in Apple's iOS Human Interface Guidelines to see what fits for your scenario.

Your method name "presentsheet" suggests you want to display something from the file, but you haven't described what it is or how much screen space it may take. Perhaps placing it into a model UIViewController would make sense, or creating a custom presentation view. You are allowed to be creative.
 
Joined
Feb 25, 2009
Messages
2,112
Reaction score
71
Points
48
Your Mac's Specs
Late 2013 rMBP, i7, 750m gpu, OSX versions 10.9.3, 10.10
Aside from the questions XStep presents -

You're adding a button to the navigation bar at the top with that code - is the nav bar even visible? Is this view controller that you are creating the custom view for even on a navigation controller stack?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top