2015-10-20 99 views
0

我想使用此代碼重新加載我的CollectionView的一些細胞的CollectionView reloadData問題,設備上迅速

var indexPathsToReload = [NSIndexPath]() 
     for var i in 0..<Data.NearByList.count { 
      indexPathsToReload.append(NSIndexPath(forItem: i, inSection: 0)) 
     } 

     collview.reloadItemsAtIndexPaths(indexPathsToReload) 

它在Xcode的模擬器進行測試時,工作正常,但是當我建立它在我的iOS設備上我有此錯誤`

*終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是: ' - [__ NSStackBlock__ _FBSDisplayDidPossiblyConnect:withScene:]:無法識別的選擇發送到實例0x41ca6c' *第一擲調用堆棧: (0×27 99386b 0x39092dff 0x27999035 0x27996c8f 0x278c62b8 0x2c2387d3 0x2c238379 0x2bb09dc3 0x2c241e7b 0x2bc82b45 0x2c2435fd 0x2bab3abd 0x2c242e25 0x2c2413fd 0x2bc7ea1d 0x199654 0x19971c 0x2babd5e3 0x2babdb63 0x2bddda0d 0x2bee9e19 0x2bde0e7d 0x2bbcddff 0x2bbcdc35 0x2bbcd7af 0x2bbcd34b 0x2badea99 0x2bade993 0x2b3741a7 0x1483dab 0x1488829 0x27956595 0x27954a8f 0x278a71e9 0x278a6fdd 0x30b4baf9 0x2bb0c18d 0x1b86dc 0x397bd873) 的libC++ abi.dylib:與終止類型NSException`

Updated這裏捕獲的異常是主要的例外

`

CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:]: 
-> 0x27998f78 <+0>: push {r4, r5, r6, r7, lr} 
    0x27998f7a <+2>: add r7, sp, #0xc 
    0x27998f7c <+4>: sub sp, #0xc 
    0x27998f7e <+6>: mov r5, r0 
    0x27998f80 <+8>: movw r0, #0xb09a 
    0x27998f84 <+12>: movt r0, #0x13f7 
    0x27998f88 <+16>: mov r4, r2 
    0x27998f8a <+18>: add r0, pc 
    0x27998f8c <+20>: ldr r1, [r0] 
    0x27998f8e <+22>: mov r0, r5 
    0x27998f90 <+24>: blx 0x279ebf9c    ; symbol stub for: __destroy_helper_block_472 
    0x27998f94 <+28>: mov r1, r5 
    0x27998f96 <+30>: mov r2, r4 
    0x27998f98 <+32>: bl  0x279996c4    ; __CFFullMethodName 
    0x27998f9c <+36>: movw r6, #0x791c 
    0x27998fa0 <+40>: mov r4, r0 
    0x27998fa2 <+42>: movt r6, #0x1223 
    0x27998fa6 <+46>: movs r0, #0x3 
    0x27998fa8 <+48>: add r6, pc 
    0x27998faa <+50>: mov r2, r4 
    0x27998fac <+52>: mov r1, r6 
    0x27998fae <+54>: mov r3, r5 
    0x27998fb0 <+56>: bl  0x2797cfb0    ; CFLog 
    0x27998fb4 <+60>: movw r0, #0xc09e 
    0x27998fb8 <+64>: movs r1, #0x0 
    0x27998fba <+66>: movt r0, #0x1220 
    0x27998fbe <+70>: mov r2, r6 
    0x27998fc0 <+72>: str r5, [sp] 
    0x27998fc2 <+74>: add r0, pc 
    0x27998fc4 <+76>: mov r3, r4 
    0x27998fc6 <+78>: ldr r0, [r0] 
    0x27998fc8 <+80>: movs r5, #0x0 
    0x27998fca <+82>: ldr r0, [r0] 
    0x27998fcc <+84>: bl  0x278b5b60    ; CFStringCreateWithFormat 
    0x27998fd0 <+88>: bl  0x278ace04    ; CFMakeCollectable 
    0x27998fd4 <+92>: mov r4, r0 
    0x27998fd6 <+94>: mov r8, r8 
    0x27998fd8 <+96>: mov r8, r8 
    0x27998fda <+98>: movw r0, #0xc0ca 
    0x27998fde <+102>: movt r0, #0x1220 
    0x27998fe2 <+106>: add r0, pc 
    0x27998fe4 <+108>: ldr r0, [r0] 
    0x27998fe6 <+110>: ldrb r0, [r0] 
    0x27998fe8 <+112>: cbz r0, 0x27998ffc   ; <+132> 
    0x27998fea <+114>: movs r0, #0x3 
    0x27998fec <+116>: mov r1, r4 
    0x27998fee <+118>: str r5, [sp] 
    0x27998ff0 <+120>: movs r2, #0x0 
    0x27998ff2 <+122>: movs r3, #0x0 
    0x27998ff4 <+124>: str r5, [sp, #0x4] 
    0x27998ff6 <+126>: str r5, [sp, #0x8] 
    0x27998ff8 <+128>: bl  0x27957b38    ; __CFRecordAllocationEvent 
    0x27998ffc <+132>: mov r0, r4 
    0x27998ffe <+134>: blx 0x279ebd5c    ; symbol stub for: ___CFPreferencesNotifyOfImpendingUserDeletion_block_invoke 
    0x27999002 <+138>: mov r3, r0 
    0x27999004 <+140>: movw r0, #0xc2d8 
    0x27999008 <+144>: movt r0, #0x1220 
    0x2799900c <+148>: movw r1, #0xb1ac 
    0x27999010 <+152>: add r0, pc 
    0x27999012 <+154>: movt r1, #0x13f7 
    0x27999016 <+158>: movw r2, #0xbbd0 
    0x2799901a <+162>: ldr r6, [r0] 
    0x2799901c <+164>: add r1, pc 
    0x2799901e <+166>: movt r2, #0x13f7 
    0x27999022 <+170>: ldr r1, [r1] 
    0x27999024 <+172>: add r2, pc 
    0x27999026 <+174>: str r5, [sp] 
    0x27999028 <+176>: ldr r0, [r2] 
    0x2799902a <+178>: ldr r2, [r6] 
    0x2799902c <+180>: blx 0x279ebf9c    ; symbol stub for: __destroy_helper_block_472 
    0x27999030 <+184>: blx 0x279ebf1c    ; symbol stub for: __NSOrderedSetEquateKeys 

`////修訂 這裏是我的colelctionview:cellforItemsatIndexPaths

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 
     // get a reference to our storyboard cell 
     let cell = collectionView.dequeueReusableCellWithReuseIdentifier(self.reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionCell 

     cell.UserID = Data.NearByList[Int(indexPath.item.value)].UserID 

     cell.personImage.image=Data.UserIDImageMap[cell.UserID] 
     cell.personImage.layer.cornerRadius=(cell.bounds.height-10)/2.0 

     if Data.NearByList[Int(indexPath.item.value)].Distance < 0.1 { 
       cell.Location.text=String("0.0")+"\nkm" 
     } 
     else 
     { 
      cell.Location.text=String(Helpers.roundNumber(Data.NearByList[Int(indexPath.item.value)].Distance))+"\nkm" 
     } 




     if Data.NearByList[Int(indexPath.item.value)].Selected == 1 
     { 
      cell.personImage.layer.borderColor = UIColor(rgb: 0x98cc00).CGColor 
      cell.personImage.alpha=1 
      cell.Location.textColor=UIColor.whiteColor() 
      cell.LocationImage.image=UIImage(named: "SelectedPin.png") 
     } 
     else 
     { 
      cell.personImage.layer.borderColor = UIColor.grayColor().CGColor 
      cell.personImage.alpha=0.5 
      cell.Location.textColor=UIColor.grayColor() 
      cell.LocationImage.image=UIImage(named: "UnSelectedPin.png") 
     } 



     cell.personImage.layer.borderWidth=3 
     cell.personImage.layer.masksToBounds=true 




     return cell 
    } 

我下載中心圖片asyncronously每下載圖像後引發該事件與SwiftEventBus和重裝的CollectionView

SwiftEventBus.onMainThread(self, name: "ReloadHomePage") { result in 
      let id=result.object as! Int 

      self.collview.reloadData() 

      // self.collview.reloadItemsAtIndexPaths([NSIndexPath(forItem: id, inSection: 0)]) 


     } 

但有些細胞不會出現像圈子,我必須滾動,使他們right.I要重新加載索引路徑爲此,此錯誤出現

回答

0

您可以請發表更多的代碼? collview的類型是什麼? 你在上面的代碼中看到選擇器異常嗎? 如果是,哪個是錯誤的選擇器名稱? 我懷疑選擇器問題與上面的代碼無關。

將更新此答案,如果我得到更多的細節:)

+0

我更新它,我不知道哪個選擇器,我添加了整個異常 –