English 中文(简体)
习俗 UIPicker 观点 - 限制使用者在某个时间带一只轮轮轮椅
原标题:custom UIPickerView - limit user to spinning one wheel at a time

我有一套习惯的“标准编码”,其中三个组成部分相互依赖(即,第二个部分根据第一和第二点选定的数值表示数值)。 我正在从<代码>NSDictionary中获取以下数值。

除我同时把两个组成部分放在一起时外,所有物体都会发生故障(没有时间重载数据)。 这是我的<条码>皮克文:didSelectRow:inComponent。 looks:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 
{
    NSLog(@"Selecting row %d component %d", row, component);

    // When A is changed, we need to reload B and C
    if (component == 0) {

        [pickerView reloadComponent:1];
        [pickerView selectRow:0 inComponent:1 animated:YES];

        // need to reload the C after reloading B
        [self pickerView:pickerView didSelectRow:0 inComponent:1];

    }
    else if (component == 1) {
        [pickerView reloadComponent:2];
        [pickerView selectRow:0 inComponent:2 animated:YES];
    }
    [self updateSelection];
}

是否有办法防止用户在防止坠机时将不止一部分人围起来?

感谢!

最佳回答

Good holy Jesus you call didSelectRow:component: recursively!

I know that the way you handle parameters prevents it from going more than two levels deep, but still, don t do that. Ever.

没有任何办法防止用户在某个时候把不止一个部分放在一起。 多托什和多瑙河的喜悦是,把一切付诸行动,看着它们都陷入一个连贯的国家。 而由于主食部分需要时间才能解决,使用者可以把他们全都用一个inger子。 你必须学会照此写你的法典。

在此情况下,请删除所有电话:didSelectRow:component:。 从内部来看,该系统只需要<>>。 你在正确轨道上使用<代码>reloadComponent:,这只是说,你没有重载:

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    NSLog(@"Selecting row %d component %d", row, component);

    [self updateSelection];

    // When A is changed, we need to reload B and C
    if (component == 0) {
        [pickerView reloadComponent:1];
        [pickerView reloadComponent:2];
    } else if (component == 1) {
        [pickerView reloadComponent:2];
    }
}

I don t know what your updateSelection does - presumably it sets the data model based on the value of pickerView. This is fine - but it needs to happen at the top of your method, so that when whichever of your titleForRow or viewForRow is called, it has the proper data to choose from. Also, from within any of those three (update,titleFor, viewFor) do not assert values into the picker! Just read from it.

我认为,这是你的良好开端,但是,在你接近你们的目标的时候,你将不得不在这里和那里 things笑事情。 我想你会发现,Pickers的关键是,他们只坚持didSelectRow:component:。 当一个构成部分把物品放在价值之上时,如果你重载,这些物品就会真正好。 如果你坐下来,看你是否能够取得某些进展,就会回头。

问题回答

Spinning two wheels at a time means you have multi-touch enabled, right? So, a possibility, may be to just disable multi-touch and limit the user to touching and affecting only one wheel in the UIPickerView.

Here s a link that might help.





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...