标签: collectionview

Backbone.Marionette CollectionView模板'undefined'

我一直在使用Brian Mann的BackboneRails截屏视频,所以我的应用程序结构完全符合这些.

以下定义了HomepageApp Marionette Appication的"show"部分.

My.module('HomepageApp.Show', function(Show, App, Backbone, Marionette, $, _){

  Show.Photo = Marionette.ItemView.extend({
    tagName:'span'
  });

  Show.Photos = Marionette.CollectionView.extend({  
    template: 'homepage/show/templates/photos',

    itemView:Show.Photo,
    itemViewContainer: '#photos'
  });

  Show.Layout = Marionette.Layout.extend({
    template: 'homepage/show/templates/layout',
    regions:{
      photoRegion: '#photo-region'
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

我也用以下内容覆盖Marionette.Renderer.render函数:

Backbone.Marionette.Renderer.render = function(template, data){
  var path = JST["backbone/apps/" + template];  

  try{
    if(!path) throw({message: "Template '" + template + "' not found!"}); 
    return path(data);
  }

  catch(err){
    console.log(err.message);
  }
}
Run Code Online (Sandbox Code Playgroud)

我的所有观点,包括许多未在此处显示的观点都完美无缺.问题是Show.Photos CollectionView的'模板'属性在我的渲染器覆盖中变为'undefined',给出了以下错误:

Template 'undefined' not found!
Run Code Online (Sandbox Code Playgroud)

奇怪的是,当我根本没有为模板属性传递任何值时,甚至会发生这种情况.

我也知道我在实例化时传递了一个有效的Backbone集合.

我完全陷入了困境.有谁熟悉这种现象?

collectionview backbone.js backbone-rails marionette

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

Marionette CollectionView带有一个独特的ItemView

有没有办法在Marionette CollectionView中创建一个独特的视图?我的意思是这样的:

的CollectionView

  • StartView(这是独特的视图)
  • 常规ItemView
  • 常规ItemView
  • 常规ItemView
  • 等等

通过唯一,我的意思是"Start ItemView"必须使用唯一的模板,而不是与常规ItemViews相关联的方法.

我试过的事情:

  • 只是将开始视图添加到CollectionView的el之前是不可取的,因为我的CollectionView的方法作用于其子视图.

  • 在Marionette文档中,建议在这种情况下覆盖buildItemView(我认为?).我不知道如何覆盖它.只是调用buildItemView不起作用,因为StartView没有关联的模型或任何选项.好像我不能把这些args留下来,或者只是返回undefined.

  • 我不能在我的CollectionView模板中包含StartView的标记,因为... Marionette CollectionViews不能有模板.

  • 从Marionette文档来看,它似乎不适合CompositeView的用例.但也许我错了.

我可能错过了一些相当明显的东西.在此先感谢您的帮助.

编辑:格式化

collectionview backbone.js marionette

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

Backbone/Marionette ItemView策略

我正在建立一个网站,其博客有一些特点.这是一种tumblr式的体验,其中有不同的后期类型:

  • Facebook的员额
  • 引用
  • 文章
  • 研究

这些职位都有一些共同的属性,如id,title,post_date,post_url_slug,但一些有一个post_imagepost_external_link为例.这是所有依赖的post_type,能容纳值,例如facebook,quote,article等这将是一个很好的策略,以确定哪种类型的它渲染时Marionette.CollectionView,要么干脆选择不同tempalte或在下划线的任意JavaScript处理这个模板我的模板?任何输入将不胜感激.

谢谢!

collectionview backbone.js marionette

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

UICollectionView滚动滞后

我在一个单元格中设置了一个包含10个子视图的集合视图.

子视图是带有标签的-imageview -text view -imageview -uilabel -imageview -uilabel

最初,集合视图在iPad上显示15个单元格.当我需要更换底部或顶部的单元格(重复使用单元格)时,滚动暂停时滚动暂停.我删除了阴影,但仍然是同样的问题.

因此,当旧单元被重用时导致滞后时会出现问题.

顺便说一句,没有图像通过网络加载.

performance scroll collectionview

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

Swift UICollectionView单元格神秘地重复

我们正在尝试收集视图。用户可以在每个单元格中选择一个图像,然后在文本字段中输入文本。我们注意到,在添加四个单元格之后,当我们添加一个新的单元格时,文本字段已经充满了先前单元格中的信息。在我们的代码中,我们永远不会以编程方式填充文本字段(该字段以空开头),我们允许用户执行此操作。有什么建议么?

  func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Image", forIndexPath: indexPath) as! CollectionViewCell
    cell.deleteButton?.addTarget(self, action: #selector(AddNewItem.xButtonPressed(_:)), forControlEvents: UIControlEvents.TouchUpInside)
    cell.deleteButton?.layer.setValue(indexPath.row, forKey: "index")
    let item = items[indexPath.item]
    let path = getDocumentsDirectory().stringByAppendingPathComponent(item.image)
    cell.imageView.image = UIImage(contentsOfFile: path)
    cell.imageView.layer.borderColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.3).CGColor
    cell.imageView.layer.borderWidth = 2
    cell.layer.cornerRadius = 7

    return cell
}
Run Code Online (Sandbox Code Playgroud)

xcode collectionview ios swift

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

XLPagerTabStrip内的Collectionview

我有一个运行的CollectionView和一个XLPagerTabStrip也运行,但是当我将我的CollectionView集成在IndicatorInfoProvider中的XLPagerTabStrip中时,我有这个错误...

在此输入图像描述

谢谢!

collectionview uicollectionview swift swift2 xlpagertabstrip

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

Swift:numberOfSectionsInCollectionView 不起作用?

好的,我在处理集合视图时遇到了问题。这就是我想要实现的 - 1 个大的 MAIN 页眉和页脚,然后嵌套在里面,需要一些数量(例如:4)个部分都只有 HEADERS。像这样:


标题主要

------
tiny header 1
------
[a][b][c]

------
tiny header 2
------
[a][b][c]
Run Code Online (Sandbox Code Playgroud)

页脚主要

查看类似的答案,我首先尝试创建不同的小节,因为现在我只有所有集合视图单元格以及一个大页脚和页眉。问题是不管我有什么,我只剩下 1 节:

 func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
        return 4
    }
Run Code Online (Sandbox Code Playgroud)

我不知道为什么。我从情节提要中获取我的收藏视图并将其设置如下:

@IBOutlet var collectionView: UICollectionView!
self.collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) //-44
        self.collectionView.backgroundColor = UIColor.white


func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {

        switch kind {

        case UICollectionElementKindSectionHeader:

            let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerCell", for: indexPath as …
Run Code Online (Sandbox Code Playgroud)

collectionview ios uicollectionviewcell swift3

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

如何在UITableView或UICollectionView中使用变量UIStackView?

我目前正在使用UICollectionView构建通用表单构建器.

每个表单元素都是一个单元格,对于复选框,我在单元格内部使用UIStackView来显示所有可用选项.

问题是,每次我重复使用单元格时,即使我删除了所有已排列的子视图,它们也会在新视图中保留.

以下代码是我正在做的简化版本:

class cell: UICollectionViewCell {

    @IBOutlet weak var stackView: UIStackView!

    func setup(options: [String]) {

        for option in options {
            let label = UILabel()
            label.text = option
            stackView.addArrangedSubview(label)
        }

    }

    override func prepareForReuse() {
        super.prepareForReuse()
        optionsStackView.arrangedSubviews.forEach({ optionsStackView.removeArrangedSubview(view: $0) })
    }

}
Run Code Online (Sandbox Code Playgroud)

而不是那样,我目前的解决方法是在prepareForReuse()中隐藏()每个arrangeSubview而不是删除它们,但我不喜欢它.

tableview collectionview ios stackview swift

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

如何在 UICollectionView 顶部制作粘性标题

目前我的 UICollectionView 中有一个标题单元格。当我尝试滚动 UICollectionView 时,标题单元格将与 UICollectionView 列表一起滚动。我可以知道如何将标题单元格设置在顶部吗?请帮忙。谢谢。

我目前的结果:- 在此输入图像描述

我的预期结果:- 在此输入图像描述

这是我的 ViewController 中标题单元格的示例代码:-

- (UICollectionView *)collectionView
{
    if (!_collectionView) {
        DCHoverFlowLayout *layout = [DCHoverFlowLayout new];
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
        _collectionView.frame = CGRectMake(0, DCTopNavH, ScreenW, ScreenH - DCTopNavH);

        _collectionView.showsVerticalScrollIndicator = NO;
        _collectionView.delegate = self;
        _collectionView.dataSource = self;

        [_collectionView registerClass:[Product_HeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:Product_HeadViewID];

    }
    return _collectionView;
}



- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {

    UICollectionReusableView *reusableview = nil;
    if (kind == UICollectionElementKindSectionHeader){

        Product_HeadView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:Product_HeadViewID forIndexPath:indexPath]; …
Run Code Online (Sandbox Code Playgroud)

header objective-c collectionview ios

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

CollectionView 不支持从与调度程序线程不同的线程更改其源集合 - 由调度程序线程引起

我有一个 ObservableCollection 和一个使用 OC 作为源的 ICollectionView:

private ObservableCollection<Comment> _Comments = new ObservableCollection<Comment>();
/// <summary>
/// Comments on the account
/// </summary>
[BsonElement("comments")]
public ObservableCollection<Comment> Comments
{
    get
    {
        return _Comments;
    }
    set
    {
        _Comments = value;
        OnPropertyChanged("Comments");
        OnPropertyChanged("CommentsSorted");
    }
}
private ICollectionView _CommentsSorted;
/// <summary>
/// Sorted list (reverse order) of the comments
/// </summary>
[BsonIgnore]
public ICollectionView CommentsSorted
{
    get
    {
        return _CommentsSorted;
    }
    set
    {
        _CommentsSorted = value;
        OnPropertyChanged("CommentsSorted");
    }
}
Run Code Online (Sandbox Code Playgroud)

我有一个命令,运行:

obj.Comments.Add(new Comment(Message));
Run Code Online (Sandbox Code Playgroud)

其中 obj 是包含可观察集合的类的实例。

调用此行时,我遇到以下异常: …

c# multithreading observablecollection collectionview

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