View Full Version : actionSheet on startup
bytezone
May 14, 2009, 04:02 PM
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:@"HomeBrewing Styles"
delegate:self
cancelButtonTitle:@"I Can't Decide"
destructiveButtonTitle:nil
otherButtonTitles:@"English", @"American", @"Imperial", nil];
[options setMessage:@"Select a Style of IPA:"];
[options showInView:self.view]; // error is here...
[windows addSubView:myView];
][window makekeyAndVisible];
dejo
May 14, 2009, 04:46 PM
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.
bytezone
May 14, 2009, 08:42 PM
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.
dejo
May 14, 2009, 10:41 PM
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 ... 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.
danielpunt
May 18, 2009, 05:31 AM
Change this:
[options showInView:self.view];
Into this:
[options show];
Also, I think this line is unnessacary:
[windows addSubView:myView];
BlackWolf
May 18, 2009, 05:51 AM
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.
CocoaPuffs
May 18, 2009, 10:41 AM
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.
BlackWolf
May 18, 2009, 01:17 PM
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.
CocoaPuffs
May 18, 2009, 06:10 PM
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.
BlackWolf
May 18, 2009, 07:36 PM
Well, in a decent UI, one should expect something more than an actionview prompt when the app is loaded.
yeah, well, I agree but that's another story ... :D
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.