Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Set selected row of UIPickerView in applicationDidFinishLaunching
Heh, well that depends largely on how you have things structured. You could put that in your viewDidLoad for the controller, or you could put it in the init (or initWithFrame ) of the view that has the pickerView on it, or you could get the value in your delegate and pass it to the view controller when that's instantiated. There's a buncha ways it could be approached. =)
My Apps on AppStore : gScale (guitar scales reference), <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=302865690" target=
Well, for setting you need to use pickerView selectRow:inComponent:animated: like in the code sample I posted above. The caveat is where is pickerView defined? It would seem from your first example that *gets* the value, your delegate has access to it in applicationWillTerminate? If so, then you should have access to it in the delegate when the app has finished launching ( and your controllers / controls etc have been created ).
Make sense? =)
My Apps on AppStore : gScale (guitar scales reference), <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=302865690" target=
OK I'm starting to understand (sorry it's my first time using the control and I'm quite new to iPhone dev). I think the problem may be the way me pickerview is set up. It is declared in the app delegate.h file but the data source and it's delegate and connected to a separate settingsviewcontroller and that is where the pickerview methods are defined.
I can see that I'm nearly there now thanks to you are selIndex holds the index of the row that needs to be selected. Now of course I just need to put in the code that selects it. Will I have to move the picker methods over the the appdelegate as this needs to be set when the application opens?
I would personally keep the delegate methods in the controller that is responsible for the view the picker is on, and then just call into that controller from the delegate to set the index to the given item on load. I like to keep my app delegate as uncluttered as possible, since things can get messy fast. =)
My Apps on AppStore : gScale (guitar scales reference), <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=302865690" target=
Pickers can have more than one spinner - each is considered a component. I believe it's a 0-based array, so if you only have one then you want to pass 0 there:
[pickerView selectedRowInComponent:0]
Once you grab that, try doing an NSLog on the value ( or set a breakpoint and step through ) to make sure you're getting what you think you should be. =)
My Apps on AppStore : gScale (guitar scales reference), <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=302865690" target=
Pickers can have more than one spinner - each is considered a component. I believe it's a 0-based array, so if you only have one then you want to pass 0 there:
[pickerView selectedRowInComponent:0]
Once you grab that, try doing an NSLog on the value ( or set a breakpoint and step through ) to make sure you're getting what you think you should be. =)
Thanks for the help exorcyze I got it working now :)
kieran12, where did you end up putting the code to pick the row in the uipicker. I have the same exact thing right now. I want it to set the row when the iser opens the program. Mine is on the main screen, always shown as the main user input.
I create the arrays that populate my picker in the viewDidload function. So I know thats not tha place to put it (I think). Since that would imply that the picker hasnt asked any of the questions regarding numer of wheels, and # of rows per row.
kieran12, where did you end up putting the code to pick the row in the uipicker. I have the same exact thing right now. I want it to set the row when the iser opens the program. Mine is on the main screen, always shown as the main user input.
I create the arrays that populate my picker in the viewDidload function. So I know thats not tha place to put it (I think). Since that would imply that the picker hasnt asked any of the questions regarding numer of wheels, and # of rows per row.
Any help would be greatly appreciated, Jason
Unfortunately I don't have the code anymore as I deleted the project but as far as I remember I put most of the code in the applicationDidFinishLaunching in my application delegate. I think saved the selected row number in to a variable and as I had done this in the app delegate it could be accessed by other classes. When the application was closed I saved the selected row using NSUserDefaults.
Replies
But I can't figure out how to restore it at launch. I tried:
but it isn't working.
Thanks for any help in advance.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeBut how do I set the UIPickerView selected row to selIndex? I tried puting:
below your code but I don't think my last part is right and it doesn't seem to be working.
Thanks exorcyze
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeMake sense? =)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI can see that I'm nearly there now thanks to you are selIndex holds the index of the row that needs to be selected. Now of course I just need to put in the code that selects it. Will I have to move the picker methods over the the appdelegate as this needs to be set when the application opens?
Thanks for your help and explaining!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeWould something like this work?
although I'm not sure what to do after that.
Thanks
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomeand I think that will work. But not there is a problem with my code that saves the preference.
I don't know what to put after selectedRowInComponent
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeOnce you grab that, try doing an NSLog on the value ( or set a breakpoint and step through ) to make sure you're getting what you think you should be. =)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI create the arrays that populate my picker in the viewDidload function. So I know thats not tha place to put it (I think). Since that would imply that the picker hasnt asked any of the questions regarding numer of wheels, and # of rows per row.
Any help would be greatly appreciated,
Jason
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf you do this in
-(void) viewWillAppear: (BOOL) animated {
[yourPickerViewName selectRow:yourRow inComponent:yourComponent animated:YES]
}
it will work. If you do it in viewWillLoad, it does not work.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome