From the beginning of this article I will be in the development process encountered every day, you can use a short article, a small demo demo to explain the small tips, share in the "iOS development Daily Small notes" in this category. The classification of the article, the content of the knowledge points may be very simple, or very short code snippets can be achieved, but in my opinion they will give the user experience, code efficiency to get some improvement, recorded here, 90% of the role is to help themselves review, memory, review. If crossing feel too easy, you can choose: 1, the "iOS Inquiry" classification, the article there treatise, 2, in the comments in this article to spit the groove, and then turn off the page! Thank!
Today, I encountered a small problem in the project: I use Uipickerview, to get the user's choice of time, the time is divided into hours and minutes two columns, and the request cannot choose 0 hours 0 minutes (that is, the minimum value is 0 hours 1 minutes).
The first thing I do is, when the user chooses a good time, click on a "Next" button, at this time to determine the user's choice, if it is 0 hours and 0 minutes, give a hint, "please reset the time." This is a more conventional approach. But when my project PL saw, said to me, whether can optimize, make user choose 0 hours 0 minutes, automatically will picker 0 minutes to choose 1 minutes? I said, "Take the app you want to copy and show it to me," PL pulled out the phone and I saw the effect he said. (In fact, the latter part is a joke O (∩_∩) o ha ha haha ~).
:
Explain: Suppose the left is an hour, optional 0 hours and 1 hours, the right is a minute, and 0-59 minutes is optional. The user can only choose between 0 hours and 1 minutes to 1 hours 59 minutes of each optional match. Now, if the user chooses 0 hours and 0 minutes, 0 minutes will automatically jump to 1 minutes. If the user selected 1 hours and 0 minutes, and then 1 hours to 0 hours, then 0 minutes will automatically turn to 1 minutes, in short, you do not have to choose 0 hours 0 minutes. The advantage of this is that the Alertview warning box is omitted for the user to click on "Reset Time". is a user-friendly experience of the promotion! (I have to say that the cause of PL is high I a raise ah, hehe ... )
Ok now say realize, I did a simple demo, put here (Https://github.com/pigpigdaddy/PickerAdvanceDemo) Please crossing treatise!
It's really simple, actually.
A few lines of key code:
1- (void) Pickerview: (Uipickerview *) Pickerview Didselectrow: (nsinteger) Row incomponent: (nsinteger) component2 {3 if(Component = =0) {4Self.hour =Row;5}Else{6Self.minute =Row;7 }8 if(Self.hour = =0&& Component = =1&& row = =0) || (Self.minute = =0&& Component = =0&& row = =0)) {9[Pickerview SelectRow:1Incomponent:1Animated:yes];Ten } One A}
Two of these properties @property:
1 @property (nonatomic, assign) Nsinteger hour; 2 @property (nonatomic, assign) Nsinteger minute;
Used to record the selected hour and minute.
This logic is really simple, not to be explained by my line.
In fact, this article on a point of view: Sometimes, stand on the user's point of view, whether our human-computer interaction experience can be better? Using the interface provided by iOS, a simple method may bring a lot of small optimization experience to the user!