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 NSRangeException (fix it by your own code) #739

Open hqlulu opened 8 years ago

hqlulu commented 8 years ago

Xcode 7.1 IOS 9.1

QSection *section1 = [[QSection alloc] initWithTitle:@"Radio element with push"];
QRadioElement *element0 = [[QRadioElement alloc] initWithItems:[NSArray arrayWithObjects:@"Football", @"Soccer", @"Formula 1", nil] selected:0];
[section1 addElement:element0];
[root addSection:section1];

click the row, then got an exception:

QuickDialogTableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (0) beyond bounds (0) for section (0)

fix it by this way:

error code at QuickDialogController.m line 116

- (void)viewWillAppear:(BOOL)animated {
    _viewOnScreen = YES;
    [self.quickDialogTableView deselectRows];
    [super viewWillAppear:animated];
    if (_root!=nil) {
        self.title = _root.title;
        self.navigationItem.title = _root.title;
        if (_root.preselectedElementIndex !=nil)
            [self.quickDialogTableView scrollToRowAtIndexPath:_root.preselectedElementIndex atScrollPosition:UITableViewScrollPositionTop animated:NO];

    }
}

set a controllerName:

QSection *section1 = [[QSection alloc] initWithTitle:@"Radio element with push"];
QRadioElement *element0 = [[QRadioElement alloc] initWithItems:[NSArray arrayWithObjects:@"Football", @"Soccer", @"Formula 1", nil] selected:0];
element0.controllerName = @"ExampleViewController";
[section1 addElement:element0];
[root addSection:section1];

code for ExampleViewController

- (void)viewWillAppear:(BOOL)animated {
    [self.quickDialogTableView reloadData];
    [super viewWillAppear:animated];
}

it can be fixed