小编Nik*_*rev的帖子

带有节的UICollectionViewFlowLayout(但没有分节符)

我目前非常简单地使用UICollectionViewFlowLayout:

UICollectionViewFlowLayout *flowLayout = [UICollectionViewFlowLayout alloc] init];
flowLayout.itemSize = CGSizeMake(75, 75);
flowLayout.minimumInteritemSpacing = 2;
flowLayout.minimumLineSpacing = 2;
_collectionView.collectionViewLayout = flowLayout;
Run Code Online (Sandbox Code Playgroud)

我有多个部分(来自不同来源的单元格),但是,我想以连续的方式渲染网格.因此,各部分之间不会有明显的中断.

请参阅屏幕截图,为了开发目的,我将在两个部分中呈现相同的单元格.

任何想法,我如何获得流程布局允许多个部分,但没有休息时间?

截图

iphone objective-c uikit ios uicollectionview

13
推荐指数
1
解决办法
927
查看次数

如何从代码中选择UICollectionView的项目/单元格

UICollectionView在我的应用程序中实现了一个.我的问题是我需要选择(如果用户点击它)一个单元格programmatically.方法:

- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath 
                     animated:(BOOL)animated 
               scrollPosition:(UICollectionViewScrollPosition)scrollPosition
Run Code Online (Sandbox Code Playgroud)

这是UICollectionView类的一部分不是我需要调用的,因为这个方法不会调用:

- (void)collectionView:(UICollectionView *)collectionView 
        didSelectItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

它只是将selected单元格的属性设置为YES;

objective-c ipad ios uicollectionview uicollectionviewcell

6
推荐指数
3
解决办法
3万
查看次数

UIMenuController sharedMenuController - 用于uicollectionview的自定义menuitem不显示在ios 7中

我正在使用a UIMenuItemUICollectionView单元长按中执行自定义操作.这与iOS 6完美配合,但现在我将我的应用程序转换为iOS 7和Xcode 5,但它无法正常工作.自定义项目未显示.

UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Unfavorite"
                                                  action:@selector(unFavorite:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:menuItem]];
[UIMenuController sharedMenuController].menuVisible = YES;

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender;
{
    //do not show default itens like copy, paste....
    [self becomeFirstResponder];
    return NO;
}


- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// The selector(s) should match your UIMenuItem selector
    if (action == @selector(unFavorite:)) {
         return YES;
    }
    return NO;
}

- (void)collectionView:(UICollectionView *)collectionView
     performAction:(SEL)action
forItemAtIndexPath:(NSIndexPath *)indexPath
        withSender:(id)sender {

}

 - (BOOL)collectionView:(UICollectionView *)collectionView
 shouldShowMenuForItemAtIndexPath:(NSIndexPath …
Run Code Online (Sandbox Code Playgroud)

objective-c uimenucontroller uicollectionview ios7

6
推荐指数
1
解决办法
9047
查看次数

无法将parentContext添加到NSManagedObjectContext,上下文已经有一个协调器

我有一个视图,我从主要检索已保存的实体(路线*)NSManagedObjectContext.我想将其导入到tempContext.按照Marcus Zarra的例子,我这​​样做:

    NSManagedObjectContext *moc = _route.managedObjectContext;
    NSManagedObjectID *routeId = [_route objectID];
    NSPersistentStoreCoordinator *psc = moc.persistentStoreCoordinator;
    self.tempContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
    [self.tempContext setPersistentStoreCoordinator:psc];
    NSManagedObject *localRoute = [self.tempContext objectWithID:routeId];
    [localRoute moToDictionary:localRoute];
    self.tempContext.parentContext = moc; // crashes here
Run Code Online (Sandbox Code Playgroud)

一切都很好,直到我尝试将parentContext我的tempContext设置为主要的MOC.我收到错误:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Context already has a coordinator;  cannot replace.'
Run Code Online (Sandbox Code Playgroud)

我明白它告诉我,我无法改变persistentStoreCoordinator.但是,我不确定为什么它会告诉我.当我设置断点时,它tempContext与主moc处于不同的内存地址.此外,self.tempContext.parentContext是零.所以我认为如果它是零,我可以将nil参数设置为moc,但它会崩溃.有什么想法吗?提前致谢!

core-data objective-c ios

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