Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bytezone

macrumors member
Original poster
Apr 20, 2009
64
0
I am not able to add actionSheet on start of the app.

In the code I am dynamically creating buttions and then adding it to view. Later I am adding view as Subview to window.

Where should I add my action sheet code....?? Also self.view is giving me error.

UIActionSheet *options = [[UIActionSheet alloc]
initWithTitle:mad:"HomeBrewing Styles"
delegate:self
cancelButtonTitle:mad:"I Can't Decide"
destructiveButtonTitle:nil
otherButtonTitles:mad:"English", @"American", @"Imperial", nil];
[options setMessage:mad:"Select a Style of IPA:"];
[options showInView:self.view]; // error is here...
[windows addSubView:myView];
][window makekeyAndVisible];
 
Where have you added this code?

Also, please use the [ CODE ] tags for your code snippets (# icon in the toolbar). Makes it easier for us read.
 
I added this to applicationDidFinishLaunching:(UIApplication *)application.

Also can you elaborate on what you meant and how it can be done...
please use the [ CODE ] tags for your code snippets ...

Where have you added this code?

Also, please use the [ CODE ] tags for your code snippets (# icon in the toolbar). Makes it easier for us read.
 
I added this to applicationDidFinishLaunching:(UIApplication *)application.
So, in your applicationDelegate. Which means it probably doesn't have a view property (unless you defined one), so self.view isn't defined. You'll probably want to move this code into your initial view controller code. Which might be a RootViewController class.

Also can you elaborate on what you meant and how it can be done...
please use the [ CODE ] tags for your code snippets ...
When composing your Reply to Thread, enclose any code snippets in
HTML:
[CODE] ... [/CODE]
tags. If you look in the toolbar above the textarea you will see an icon that looks like a # symbol. This will get you started with the tags you need.
 
Change this:
Code:
[options showInView:self.view];
Into this:
Code:
[options show];

Also, I think this line is unnessacary:
Code:
[windows addSubView:myView];
 
note that cocoa touch is case sensitive. so "makekeyAndVisible" won't work, neither will "addSubView". also, it's "window" not "windows" - which will produce another error.

also, if you are using this in your application delegate than it's likely to be in the wrong place. you add the actionSheet to "self.view" - what view is that? where did you create it? you should move this code to your viewController's "viewDidLoad" method.
if you need to show it before a view is shown, then you should use "self.window" instead of "self.view" - since you want to add it to the window then, since nothing else exists.
 
Load some plain view class and put the actionsheet code in that view class file. You shouldn't make a mess in the appdelegate file, which you will with actionsheetdelegate methods that you also have to add.
 
Load some plain view class and put the actionsheet code in that view class file. You shouldn't make a mess in the appdelegate file, which you will with actionsheetdelegate methods that you also have to add.

well, I'm not an expert programmer but I would disagree. Logically, if the actionsheet is supposed to pop up before anything is displayed (for example because the actionsheet decides which view is shown at startup) I would probably put it in the appDelegate - because that's the code that shows the initial view.
 
well, I'm not an expert programmer but I would disagree. Logically, if the actionsheet is supposed to pop up before anything is displayed (for example because the actionsheet decides which view is shown at startup) I would probably put it in the appDelegate - because that's the code that shows the initial view.

Well, in a decent UI, one should expect something more than an actionview prompt when the app is loaded.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.