【发布时间】:2014-01-20 21:28:16
【问题描述】:
我目前正在测试我的应用程序,尤其是在 iPhone 4s 上。并且一些简单的 UI 任务似乎滞后和延迟,例如在集合视图中选择图像或更改 UI 复选框的状态。有没有更好的方法来做到这一点?我需要在这里做一些异步的事情吗?如果某些内容发生了变化,CoreData 中的属性也会发生变化,但这会那么慢吗?
CollectionView(图片名称都保存在viewdidload的数组中):
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"IconCell";
IconSelectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
cell.iconImageView.image = [UIImage imageNamed:[self.icons objectAtIndex:indexPath.row]];
return cell;
}
#pragma mark Collection View Delegate methods
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
self.mainCategory.icon = [self.icons objectAtIndex:indexPath.row];
}
以 UISwitch 为例:
- (IBAction)liveBudgetSwitched:(id)sender
{
self.spendingCategory.liveBudget = [NSNumber numberWithBool: self.liveBudgetSwitch.on];
}
【问题讨论】:
-
您是否在 Core Data 中保存图像?它们有多大?
-
不,只是字符串。如您在此处看到的: cell.iconImageView.image = [UIImage imageNamed:[self.icons objectAtIndex:indexPath.row]];只是字符串被保存和使用。尤其是 UISwitch 很奇怪不是吗?有时(并非总是)当您单击它时,它会保持相同的状态大约 1 秒钟,然后才会切换。很混乱。而且 coredata 连接应该没问题,因为我使用了苹果的模板并且根本没有改变任何东西。也许它与当前的另一个问题有关:stackoverflow.com/questions/20900310/…
标签: ios objective-c core-data uicollectionview uiswitch