我试图使用此代码重新加载我的collectionView的一些单元格,
var indexPathsToReload = [NSIndexPath]()
for var i in 0..<Data.NearByList.count {
indexPathsToReload.append(NSIndexPath(forItem: i, inSection: 0))
}
collview.reloadItemsAtIndexPaths(indexPathsToReload)
在Xcode的模拟器中测试时效果很好,但是当我在iOS设备上构建时,我有这个错误`
*由于未捕获的异常终止应用程序&#39; NSInvalidArgumentException&#39;,原因:&#39; - [__ NSStackBlock__ _FBSDisplayDidPossiblyConnect:withScene:]:无法识别的选择器发送到实例0x41ca6c&#39; * 第一次抛出调用堆栈: (0x2799386b 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
}
我异步下载图像,每次下载的图像后都使用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)])
}
但是有些单元格看起来不像圆形,我必须滚动才能使它们正确。我想在索引路径重新加载此错误并显示此错误
答案 0 :(得分:0)
您能发布更多代码吗? collview的类型是什么? 您是否在上述代码中看到了选择器异常? 如果是,那么选择器名称是错误的? 我怀疑选择器问题与上面的代码无关。
如果我得到更多详细信息,将更新此答案:)