escoz / QuickDialog

QuickDialog - Quick and easy dialog screens for iOS
http://escoz.com/open-source/quickdialog
Other
3.07k stars 637 forks source link

QRadioElement selected item not appearing as default value #617

Closed kayrules closed 10 years ago

kayrules commented 10 years ago

If QRadioElement initiated "without" title parameter, it will not showing the default value as per defined. no checkmark showed on the detail view. But if manually selected, the value will appear as normal.

[root addSection:section1];
[section1 addElement:[[QRadioElement alloc] initWithItems:[NSArray arrayWithObjects:@"Football", @"Soccer", @"Formula 1", nil] selected:0]];

I'm not sure if this is valid issue or not, because it even happened on demo project.

kayrules commented 10 years ago

Changing the original code in QRadioElement.m line 78 & 86 to codes below should fix it:

- (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSInteger)selected {
    self = [self initWithItems:stringArray selected:selected title:nil];
    _selected = selected; //<-- Initially _selected = -1;
    return self;
}

- (QRadioElement *)initWithDict:(NSDictionary *)valuesDictionary selected:(int)selected title:(NSString *)title {
    self = [self initWithItems:valuesDictionary.allKeys selected:(NSUInteger) selected];
    _values = valuesDictionary.allValues;
    _selected = selected; //<-- Initially _selected = -1;
    self.title = title;
    return self;
}