Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS 13上的UIScrollView中设置UIRefreshControl_Ios_Swift_Ios13 - Fatal编程技术网

在iOS 13上的UIScrollView中设置UIRefreshControl

在iOS 13上的UIScrollView中设置UIRefreshControl,ios,swift,ios13,Ios,Swift,Ios13,我在滚动视图中添加了UIRefreshControl,它在iOS 13下运行良好,但当我在iOS 13上运行相同的应用程序时,它会与下面的日志崩溃 在ScrollView上添加UIRefreshControl 事故日志 MyApp测试[33324:98294]***由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“从-traitCollection返回了nil,这是不允许的。” ***第一次抛出调用堆栈: ( 0 CoreFoundati

我在滚动视图中添加了
UIRefreshControl
,它在iOS 13下运行良好,但当我在iOS 13上运行相同的应用程序时,它会与下面的日志崩溃

在ScrollView上添加UIRefreshControl

事故日志

MyApp测试[33324:98294]***由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“从-traitCollection返回了nil,这是不允许的。”
***第一次抛出调用堆栈:
(
0 CoreFoundation 0x00007fff23b98bde例外预处理+350
1 libobjc.A.dylib 0x00007fff503b5b20 objc_异常_抛出+48
2 CoreFoundation 0x00007fff23b98958+[N异常提升:格式:参数:][88
3基金会0x000 7FFF255EB7BE-[NSRealStutsHuffer-HuffLeaReuleNoff:Fiel:No.No.No:::+] 166
4 UIKitCore 0x00007fff46dd08bd_UIGetCurrentFallbackTraitCollection+962
5 UIKitCore 0x00007fff476029fa UIViewCommonInitWithFrame+617
6 UIKitCore 0x00007FFF4762753-[UIView initWithFrame:][98
7 UIKitCore 0x00007fff46b910bb-[\u UIRefreshControlModernContentView initWithFrame:][70
8 UIKitCore 0x00007FFF4646343D-[UIRefreshControl_contentView]+150
9 UIKitCore 0x00007FFF464631AB-[UIRefreshControl sizeToFit]+52
10 UIKitCore 0x00007FFF464632B1-[UIRefreshControl didMoveToSuperview]+178
11 UIKitCore 0x00007fff476207de\uuuu 45-[UIView(层次结构)\uPostMovedFromSuperView:]\uBlock\uInvoke+1010
12 UIKitCore 0x00007fff47620373-[UIView(层次结构)\u postMovedFromSuperview:+753
13 UIKitCore 0x00007fff4762fb45-[UIView(内部)\u addSubview:定位:相对位置:][1718
14 UIKitCore 0x00007fff475c396d-[UIScrollView\u addContentSubview:atBack:+564
15 UIKitCore 0x00007FFF47BF3DF-[UIScrollView\u setRefreshControl:+248
16 UIKitCore 0x00007FFF47BF265-[UIScrollView setRefreshControl:+67
17 MyApp测试0x000000010d5cd02e$s14MyApp_测试14输出VCC13 PullToRefreshyyyf+270
18 MyApp测试0x000000010d5cce7e$s14MyApp_测试14输出VCC11VIEWDIDLOADDYYF+190
19 MyApp测试0x000000010d5ccf0b$s14MyApp_测试14输出VCC11ViewDidLoadyFTO+43
20 UIKitCore 0x00007fff46af87c2-[UIViewController\u SendViewDidLoadWith AppearanceProxyObjectTaggingEnabled]+83
21 UIKitCore 0x00007fff46afd6d3-[UIViewController LoadViewIf Required]+1084
22 UIKitCore 0x00007FFF46AFAF0-[UIViewController视图]+27
23 UIKitCore 0x00007fff46a81dbf-[UIPageViewController\U setViewControllers:WITHCROLINDIY:动画:完成:[538
24 UIKitCore 0x00007fff46a81fd3-[UIPageViewController setViewControllers:方向:动画:完成:][263
25 CarbonKit 0x000000010e3afb01-[CarbonTabSwipenAgation loadFirstViewController]+705
26 CarbonKit 0x000000010e3aaba1-[CarbonTabSwipenAviation initWithItems:工具栏:委托:][289
27 MyApp测试0x000000010d32960a$SSO24CarbontabswipenavigationC5Items7Toolbar8DelegateAbsayPgsg_So9UIToolbarCyptcfcTO+250
28 MyApp测试0x000000010d32828a$SSO24CarbontabswipenavigationC5Items7Toolbar8DelegateAbsayPgsg_So9UIToolbarCyptcfC+58
29 MyApp测试0x000000010d327159$s14MyApp_测试15额定主选项卡VCC11VIEWDIDLOADDYYF+409
30 MyApp测试0x000000010d3282cb$s14MyApp_测试15额定主选项卡VCC11ViewDidLoadyyFTO+43
31 UIKitCore 0x00007fff46af87c2-[UIViewController\u SendViewDidLoadWith AppearanceProxyObjectTaggingEnabled]+83
32 UIKitCore 0x00007fff46afd6d3-[UIViewController loadViewIfRequired]+1084
33 UIKitCore 0x00007fff46a6208c-[UINavigationController\u更新从VIEWCONTROLLER:到VIEWCONTROLLER:+160的滚动视图
34 UIKitCore 0x00007fff46a6238c-[UINavigationController\u开始转换:从ViewController:到ViewController:+140
35 UIKitCore 0x00007fff46a63256-[UINavigationController\u STARTDEFERREEDTRANSION(如果需要):+868
36 UIKitCore 0x00007fff46a645c1-[UINavigationController\uuu视图将布局子视图]+150
37 UIKitCore 0x00007fff46a45ffb-[UILayoutContainerView布局子视图]+217
38 UIKitCore 0x00007fff47636722-[UIView(CALayerDelegate)布局层的子层:+2478
39夸脱芯0x00007fff2b030ef9-[CALayer layoutSublayers]+255
40夸脱芯0x00007fff2b0358ff(如果需要)层布局交易+517
41 QuartzCore 0x00007fff2b041fe4 _Zn2Ca5层28布局_和_显示(如果需要)事务处理+80
42 QuartzCore 0x00007fff2af8a4a8_ZN2CA7Context18commit_TransactionPNS_11 Transactiond+324
43夸脱芯0x00007fff2afbfab3_Zn2Ca11交易承诺+643
44 UIKitCore 0x00007fff4715c27c_UIU应用程序FlushRunLopCatTransactionIftoolate+104
45 UIKitCore 0x00007fff471fd878 _u-handleEventQueueInternal+6902
46 CoreFoundation 0x00007fff23afbac1\uuu CF
let refresh = UIRefreshControl()

    //Scroll View main
    @IBOutlet weak var scrollViewMain: UIScrollView!



    override func viewDidLoad() {
        super.viewDidLoad()
        pullToRefresh()

    }

    func pullToRefresh(){
        refresh.addTarget(self, action: #selector(handleTopRefresh(_:)), for: .valueChanged )
        refresh.tintColor = UIColor.themeAppColor
        self.scrollViewMain.refreshControl = refresh
      }
    @objc func handleTopRefresh(_ sender:UIRefreshControl){
        getOutletRatings()
    }
MyApp Test[33324:98294] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<MyApp_Test.OutletRatingVC: 0x7faa2e806a00> returned nil from -traitCollection, which is not allowed.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23b98958 +[NSException raise:format:arguments:] + 88
    3   Foundation                          0x00007fff255eb7be -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    4   UIKitCore                           0x00007fff46dd08bd _UIGetCurrentFallbackTraitCollection + 962
    5   UIKitCore                           0x00007fff476029fa UIViewCommonInitWithFrame + 617
    6   UIKitCore                           0x00007fff47602753 -[UIView initWithFrame:] + 98
    7   UIKitCore                           0x00007fff46b910bb -[_UIRefreshControlModernContentView initWithFrame:] + 70
    8   UIKitCore                           0x00007fff46b6343d -[UIRefreshControl _contentView] + 150
    9   UIKitCore                           0x00007fff46b631ab -[UIRefreshControl sizeToFit] + 52
    10  UIKitCore                           0x00007fff46b632b1 -[UIRefreshControl didMoveToSuperview] + 178
    11  UIKitCore                           0x00007fff476207de __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 1010
    12  UIKitCore                           0x00007fff47620373 -[UIView(Hierarchy) _postMovedFromSuperview:] + 753
    13  UIKitCore                           0x00007fff4762fb45 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1718
    14  UIKitCore                           0x00007fff475c396d -[UIScrollView _addContentSubview:atBack:] + 564
    15  UIKitCore                           0x00007fff475bf3df -[UIScrollView _setRefreshControl:] + 248
    16  UIKitCore                           0x00007fff475bf265 -[UIScrollView setRefreshControl:] + 67
    17  MyApp Test                      0x000000010d5cd02e $s14MyApp_Test14OutletRatingVCC13pullToRefreshyyF + 270
    18  MyApp Test                      0x000000010d5cce7e $s14MyApp_Test14OutletRatingVCC11viewDidLoadyyF + 190
    19  MyApp Test                      0x000000010d5ccf0b $s14MyApp_Test14OutletRatingVCC11viewDidLoadyyFTo + 43
    20  UIKitCore                           0x00007fff46af87c2 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
    21  UIKitCore                           0x00007fff46afd6d3 -[UIViewController loadViewIfRequired] + 1084
    22  UIKitCore                           0x00007fff46afdaf0 -[UIViewController view] + 27
    23  UIKitCore                           0x00007fff46a81dbf -[UIPageViewController _setViewControllers:withScrollInDirection:animated:completion:] + 538
    24  UIKitCore                           0x00007fff46a81fd3 -[UIPageViewController setViewControllers:direction:animated:completion:] + 263
    25  CarbonKit                           0x000000010e3afb01 -[CarbonTabSwipeNavigation loadFirstViewController] + 705
    26  CarbonKit                           0x000000010e3aaba1 -[CarbonTabSwipeNavigation initWithItems:toolBar:delegate:] + 289
    27  MyApp Test                      0x000000010d32960a $sSo24CarbonTabSwipeNavigationC5items7toolBar8delegateABSayypGSg_So9UIToolbarCyptcfcTO + 250
    28  MyApp Test                      0x000000010d32828a $sSo24CarbonTabSwipeNavigationC5items7toolBar8delegateABSayypGSg_So9UIToolbarCyptcfC + 58
    29  MyApp Test                      0x000000010d327159 $s14MyApp_Test15RatingMainTabVCC11viewDidLoadyyF + 409
    30  MyApp Test                      0x000000010d3282cb $s14MyApp_Test15RatingMainTabVCC11viewDidLoadyyFTo + 43
    31  UIKitCore                           0x00007fff46af87c2 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
    32  UIKitCore                           0x00007fff46afd6d3 -[UIViewController loadViewIfRequired] + 1084
    33  UIKitCore                           0x00007fff46a6208c -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 160
    34  UIKitCore                           0x00007fff46a6238c -[UINavigationController _startTransition:fromViewController:toViewController:] + 140
    35  UIKitCore                           0x00007fff46a63256 -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
    36  UIKitCore                           0x00007fff46a645c1 -[UINavigationController __viewWillLayoutSubviews] + 150
    37  UIKitCore                           0x00007fff46a45ffb -[UILayoutContainerView layoutSubviews] + 217
    38  UIKitCore                           0x00007fff47636722 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
    39  QuartzCore                          0x00007fff2b030ef9 -[CALayer layoutSublayers] + 255
    40  QuartzCore                          0x00007fff2b0358ff _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
    41  QuartzCore                          0x00007fff2b041fe4 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
    42  QuartzCore                          0x00007fff2af8a4a8 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
    43  QuartzCore                          0x00007fff2afbfab3 _ZN2CA11Transaction6commitEv + 643
    44  UIKitCore                           0x00007fff4715c27c _UIApplicationFlushRunLoopCATransactionIfTooLate + 104
    45  UIKitCore                           0x00007fff471fd878 __handleEventQueueInternal + 6902
    46  CoreFoundation                      0x00007fff23afbac1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    47  CoreFoundation                      0x00007fff23afb9ec __CFRunLoopDoSource0 + 76
    48  CoreFoundation                      0x00007fff23afb1c4 __CFRunLoopDoSources0 + 180
    49  CoreFoundation                      0x00007fff23af5ecf __CFRunLoopRun + 1263
    50  CoreFoundation                      0x00007fff23af56b6 CFRunLoopRunSpecific + 438
    51  GraphicsServices                    0x00007fff3815cbb0 GSEventRunModal + 65
    52  UIKitCore                           0x00007fff47162a67 UIApplicationMain + 1621
    53  MyApp Test                      0x000000010d4769cb main + 75
    54  libdyld.dylib                       0x00007fff5123bcf5 start + 1
    55  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
func pullToRefresh() {
    if scrollViewMain.refreshControl == nil {
        refresh.addTarget(self, action: #selector(handleTopRefresh(_:)), for: .valueChanged )
        refresh.tintColor = UIColor.blue
        self.scrollViewMain.refreshControl = refresh
    }
}