Is tangled day. . . .
Every question can get help heroes, brother grateful! In this thanked ~
Another problem ~ ~ ~ ~ ~ ~
I click on a button, add a picker View view, there is a corresponding choice in the use of "three kilometers", "2 km", "one kilometer", "500 meters" these four values. The selected already. But I want when I choose "3 km" when, button along with the title changed to "3 km." Select "two kilometers" when, button along with the title changed to "2 km." I set the title of the function is setTitle: @ "" forState; to set up.
The problem came. . . . I have this [btn setTitle: @ "" forState]; Where do you want to call? If I respond to a button function ----- (IBAction) call, then press the button next only when it takes effect. I want to - (void) pickerView: (UIPickerView *) pickerView didSelectRow: (NSInteger) row inComponent: (NSInteger) component {} call, not visit the parent view control in this function, which is accessed less btn, so there is no way to set btn the title. What a way to achieve this effect me? Thank you! ! !
Reply:
Do not use a simple notification mechanism to achieve a ~
Reply:
delegate, or upstairs, NSNotification
Or performSelector
But why not visit button do? Do not understand
Reply:
Thank you brothers to help me every time. Grateful ah ~ ~ ~ The most important commission, I do not have, alas, every time I pass a function return values are used for! Very say tragedy. Now want to use the approach in a button handler directly alloc a UIPickerView (before I was to build a single view, and then add), and then followed them for processing. But because there are several buttons have alloc UIPickerView, so when the process will be more complicated! Reprocessing tomorrow.
Reply:
This really is not ~ ~ ~ Oh did not learn the most basic, my level is still stuck in the C and C + +, based on the many ideas do not turn around!
Reply:
Hey. . . . A floor that is not ah. . . . Rookie drifting
Reply:
Why can not call it? ? The problem is purely design pattern. You have a good think about refactoring your code. Do not spend the time to fully immersed write code, think about architecture, object-oriented features to think about, your problems will be solved.
Reply:
Ah heroes right, projects, Reflections on the efficiency of the project is often much higher than the project write code efficiency!
Reply:
The parent class passed as a pointer to the picker view! ! !
http://blog.csdn.net/orietech
ORIETech
Reply:
Pickerview then call the parent class pointer, button settitle
and parent class
Or
with deleget
Reply:
Cai Cai top
Reply:
They are not inherited, if the inheritance would be much easier. Only reference relationship!
No comments:
Post a Comment