iOS 11上的UIDate Picker崩溃

时间:2018-01-25 07:36:56

标签: ios swift xcode ios11 uidatepicker

我一直试图了解代码的错误,因为我在iOS 11上遇到随机崩溃:

  

致命异常:NSRangeException   *** - [__ NSArrayM objectAtIndex:]:索引9223372036854775807超出界限[0 .. 1]

这是我设置日期选择器的代码:

function hasPermission (user, roles) {
  roles.forEach(role => {
    user[role] // is not working as user keys named differently
  })
}

崩溃日志:

0  CoreFoundation                 0x186bc1d04 __exceptionPreprocess
1  libobjc.A.dylib                0x185e10528 objc_exception_throw
2  CoreFoundation                 0x186b5abd4 _CFArgv
3  CoreFoundation                 0x186a8a9a0 -[__NSArrayM removeObjectAtIndex:]
4  UIKit                          0x19024d2c4 -[UIPickerView selectedRowInComponent:]
5  UIKit                          0x190ac3f24 -[_UIDatePickerMode_Date _dateForYearRow:]
6  UIKit                          0x190ac0ad8 -[_UIDatePickerMode dateForRow:inCalendarUnit:]
7  UIKit                          0x190ac1770 -[_UIDatePickerMode _updateSelectedDateComponentsWithNewValueInComponent:usingSelectionBarValue:]
8  UIKit                          0x190ac1a18 -[_UIDatePickerMode selectedDateComponents]
9  UIKit                          0x190ac408c -[_UIDatePickerMode_Date _shouldEnableValueForRow:inComponent:calendarUnit:]
10 UIKit                          0x190ac2c3c -[_UIDatePickerMode _shouldEnableValueForRow:column:]
11 UIKit                          0x190ac2788 -[_UIDatePickerMode viewForRow:inComponent:reusingView:]
12 UIKit                          0x190ab6380 -[_UIDatePickerView pickerView:viewForRow:forComponent:reusingView:]
13 UIKit                          0x19024d9ec -[UIPickerView tableView:cellForRowAtIndexPath:]
14 UIKit                          0x190aa65d4 -[UIPickerColumnView tableView:cellForRowAtIndexPath:]
15 UIKit                          0x19033393c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
16 UIKit                          0x190333ea0 -[UITableView _createPreparedCellForGlobalRow:willDisplay:]
17 UIKit                          0x1903139e4 -[UITableView _updateVisibleCellsNow:isRecursive:]
18 UIKit                          0x19031df88 -[UITableView _cellForRowAtIndexPath:usingPresentationValues:]
19 UIKit                          0x1901117a4 -[UITableView cellForRowAtIndexPath:]
20 UIKit                          0x1908e6c80 __61-[UIPickerTableView selectRow:animated:notify:updateChecked:]_block_invoke
21 Foundation                     0x187565b70 __NSIndexSetEnumerate
22 UIKit                          0x1908e691c -[UIPickerTableView selectRow:animated:notify:updateChecked:]
23 UIKit                          0x19024d618 -[UIPickerView _selectRow:inComponent:animated:notify:]
24 UIKit                          0x190ab49e4 -[_UIDatePickerView _selectRow:inComponent:animated:notify:]
25 UIKit                          0x190ac13f4 -[_UIDatePickerMode loadDate:animated:]
26 UIKit                          0x190ab4998 -[_UIDatePickerView _loadDate:animated:]
27 UIKit                          0x190ab4020 -[_UIDatePickerView _setDate:animated:forced:]
28 UIKit                          0x190ab4578 -[_UIDatePickerView _setMode:]
29 UIKit                          0x190ab4694 -[_UIDatePickerView setDatePickerMode:]

1 个答案:

答案 0 :(得分:0)

您的In [50]: img = np.random.randint(0, 255, (3, 180, 480, 640), dtype=np.uint8) In [51]: img1 = np.squeeze(img[:, 9:10]) # proper_img is a *view*; caution while modifying it In [52]: proper_img = np.moveaxis(img1, source=0, destination=-1) In [53]: plt.imshow(proper_img) 已在函数中创建。只要datePickerView返回,就会释放该变量。

您需要将setUpPickerView变量作为视图控制器的一部分,如下所示:

datePickerView