【问题标题】:Drag and drop from Collectionview into ContactViewController doesn't work on iPad从 Collectionview 拖放到 ContactViewController 在 iPad 上不起作用
【发布时间】:2014-03-24 04:20:33
【问题描述】:

我正在开发一个使用 splitView 的应用程序。

我在 splitView 中使用了两个项目(分别称为 CustomerSupplier)。

当我点击其中一个时,我只使用一个 viewController 来显示(称为:ContactViewController),我使用 collectionView 来显示它的数据。要获取数据,我只需对其进行编码:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    if (!dbManager.synchronized) {
        if (contactType == ContactTypeCustomer)
            [dbManager requestData:kDbCustomers predicate:nil target:self];
        else if (contactType == ContactTypeSuppplier)
            [dbManager requestData:kDbSuppliers predicate:nil target:self];
    }
}

当获得成功时:

#pragma mark
#pragma DBDelegate

- (void)requestDataCompleted:(NSMutableArray *)results
{
    datasource = results;
    [self.collectionView reloadData];
}

我使用从github.com下载的I3DragBetweenHelper

嵌入到我的应用程序中以进行初始拖放。为此,我将以下方法调用到 ContactViewController

viewDidLoad
- (void) initDragAndDrop
{
    self.helper = [[I3DragBetweenHelper alloc] initWithSuperview:self.view
                                                         srcView:_collectionView
                                                         dstView:_collectionView];
    self.helper.delegate = self;
    self.helper.isDstRearrangeable = NO;
    self.helper.isSrcRearrangeable = NO;
    self.helper.doesSrcRecieveDst = NO;
    self.helper.doesDstRecieveSrc = YES;
    self.helper.hideDstDraggingCell = YES;
    self.helper.hideSrcDraggingCell = NO;
}

这里的助手是: @property (strong, nonatomic) I3DragBetweenHelper *helper;

问题是当我点击Supplier时,我可以collectionView的单元格拖放到ContactViewController中.以下方法已调用并有效: - (BOOL)droppedOutsideAtPoint:(CGPoint)pointIn fromDstIndexPath:(NSIndexPath *)from

但是当我点击 Customer 时,上面的方法没有调用。我什至无法将我的 collectionView 单元格拖到 ContactViewController 中。任何帮助将不胜感激。

【问题讨论】:

  • 无法在 iPad 上运行 ..这意味着您的应用在其他 iOS 设备上运行?
  • 另一个人编辑了我的问题标题。我的 iPad 应用程序可以工作,但不是全部。请阅读我的问题。

标签: ios objective-c drag-and-drop


【解决方案1】:

为什么isDstRearrangeable 设置为NO ???因为最终你会抓住一些东西并将它放到某个东西(dest)上,而那个东西(dest)会被重新排列,我错了吗??

您的拖放是否发生在同一个地方? (即:UICollectionView

如果是这样,那为什么 src 不可重新排列???您的目的地和 src 都应该是可重新排列的。

试试这个,让我知道结果如何:)

【讨论】:

  • +我尝试将isDstRearrangeable 更改为YES,但它也不起作用。 +当我将 cell 拖出 collectionView 时,该单元格将被删除,collectionView 将重新加载 cell 和数据.我使用相同的 viewcontroller 将数据显示到 collectionView
  • 但是当这个 viewController 设置为供应商时,拖放才起作用。不知道为什么数据设置为Customer,然后不能拖动。
【解决方案2】:

我不知道这个库,但我认为问题是你的 srcView 和 dstView 是一样的。这些应该是不同的,并且必须是 UITableView 或 UICollectionView。

如果您使用的是 UISplitViewController,它可能是 UISplitView 使用的主视图控制器和详细视图控制器

【讨论】:

  • 不,不是问题。因为正如我上面写的那样,它在供应商中工作。
猜你喜欢
  • 2014-02-22
  • 1970-01-01
  • 1970-01-01
  • 2011-05-29
  • 2022-11-29
  • 2013-08-06
  • 2021-11-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多