小编Jdi*_*zle的帖子

UICollectionView reloadItemsAtIndexPaths

我一直试图绕过UICollectionView的reloadItemsAtIndexPaths方法.

我有一个名为objectsArray的对象数组.当用户滚动到我的集合视图的底部时,我从后端获取下一批对象,并通过调用[objectsArray addObjectsFromArray:objects]将其附加到objectsArray; 这样做后,我调用[self.collectionView reloadData],我知道这是昂贵的.

我想用下面的代码进行优化,但是在调用reloadItemsAtIndexPaths时我得到一个断言失败.

    if (self.searchPage == 0) {
        parseObjectsArray = [[NSMutableArray alloc] initWithArray:relevantDeals];
        [self.collectionView reloadData];

    } else {

        NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
        for (int i = 0; i < [relevantDeals count]; i++) {
            NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
            [indexPaths addObject:indexPath];
        }

        [parseObjectsArray addObjectsFromArray:relevantDeals];
        [self.collectionView reloadItemsAtIndexPaths:indexPaths];
        //[self.collectionView reloadData];
    }
Run Code Online (Sandbox Code Playgroud)

错误: *断言失败 - [UICollectionView _endItemAnimations],/ SourceCache/UIKit/UIKit-2903.2/UICollectionView.m:3716

非常感谢任何帮助/提示.

谢谢!

xcode pagination nsindexpath uicollectionview

4
推荐指数
1
解决办法
1万
查看次数

正确实例化UISearchDisplayController

我做了一些搜索,答案仍然不清楚.我试图在TableViewController(TVC)中创建一个UISearchDisplayController的实例.

在我的TVC的标题中,我将searchDisplayController声明为属性:

@interface SDCSecondTableViewController : UITableViewController

@property (nonatomic, strong) NSArray *productList;
@property (nonatomic, strong) NSMutableArray *filteredProductList;
@property (nonatomic, strong) UISearchDisplayController *searchDisplayController;

@end
Run Code Online (Sandbox Code Playgroud)

这样做会产生错误:

属性'searchDisplayController'试图使用超类'UIViewController'中声明的实例变量'_searchDisplayController'

添加@synthesize searchDisplayController实现文件摆脱了错误.

任何人都可以帮我理解这个错误吗?我正在使用Xcode 4.6.2,但我认为属性是从Xcode 4.4开始自动合成的.

properties searchdisplaycontroller ios xcode4.6

3
推荐指数
1
解决办法
1827
查看次数

indexofobject返回零

我正在尝试使用从故事板构建的场景来构建应用程序的演练.

所以我填充了我的viewControllers数组,称为pages:

@interface PVCPagesViewController () {
    NSMutableArray *pages;
}

@property (retain, nonatomic) NSMutableArray *pages;
@property (strong, nonatomic) UIPageViewController *pageController;


@end
Run Code Online (Sandbox Code Playgroud)

在viewDidLoad()中:

self.pages = [[NSMutableArray alloc] init];

UIViewController *page1 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page1"];

UIViewController *page2 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page2"];

UIViewController *page3 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page3"];

UIViewController *page4 = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"page4"];

self.pages = [[NSMutableArray alloc] initWithObjects:page1, page2, page3, page4, nil];
Run Code Online (Sandbox Code Playgroud)

但是当我要在viewControllerAfterViewController()中从数组加载另一个视图控制器时:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {

    NSInteger index = [self.pages indexOfObject:viewController];

    index++;

    return [self.pages objectAtIndex:index]; …
Run Code Online (Sandbox Code Playgroud)

objective-c nsmutablearray uipageviewcontroller

3
推荐指数
1
解决办法
1048
查看次数

backbone.js集合where()函数

我正在读一本关于JS快速原型制作的书.这行代码:

var appleModel = this.collection.where({name: appleName})[0];
Run Code Online (Sandbox Code Playgroud)

我知道where()在集合中返回匹配的模型.但到底是[0]做什么的呢?

javascript where backbone.js

2
推荐指数
1
解决办法
8420
查看次数