小编Hil*_*ich的帖子

UICollectionView仅显示一个单元格 - 在滚动视图时会更改

我有一个UICollectionView,它应该显示数组中的项目.我检查了数组 - 并且填充了正确的数字和对象类型.

但是,UICollectionView只显示一个UICollectionView单元格 - 当我将单元格拉到前一个对象时,它会发生变化.我之前没见过这种行为.以下是我的代码:

(导致问题的是SourceTankCollectionView(我假设目标集合视图​​单元格也是如此)

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (collectionView==self.movementsIndexCollectionView)
    {

        TransfersListCollectionViewCell* tempCell = [collectionView dequeueReusableCellWithReuseIdentifier: @"Transfer List Cell" forIndexPath:indexPath];
        if (!tempCell)
        {
            tempCell = [[TransfersListCollectionViewCell alloc] init];
        }

        Movement* thisMovement = [self.arrayOfAllMovements objectAtIndex:indexPath.item];

        tempCell.sourceTankLabel.text = thisMovement.sourceTank.tankNumber;
        tempCell.destinationTankLabel.text = thisMovement.destinationTank.tankNumber;
        tempCell.layer.borderWidth = 1.5;
        tempCell.layer.borderColor = [[UIColor darkGrayColor] CGColor];
        tempCell.layer.cornerRadius = 4;
        return tempCell;
    }

    else if (collectionView==self.sourceTanksCollectionView)
    {
        SourceTankCollectionViewCell* tempCell = [collectionView dequeueReusableCellWithReuseIdentifier: @"Source Tank Collection Cell" forIndexPath:indexPath];
        if (!tempCell)
        {
            tempCell = [[SourceTankCollectionViewCell …
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview uicollectionviewcell

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

从二进制文件解包双值

我知道在 Python 中读取 C double 值存在问题。在我的程序中,我从二进制文件中读取并将数值转换为各种大小的整数,没有问题。我使用下面的代码来读取双精度值。

peakDescriptor["area"] = struct.unpack("d",file.read(8))
Run Code Online (Sandbox Code Playgroud)

价值观应该是什么和我得到什么之间存在巨大差异。下面的第一个表是我所得到的:
甲烷3.6368230562528605e-307
乙烷-8.243249632731949e + 306
丙烷1.839329701286865e-60
2-甲基-2.55127317345224e-306
丁烷3.737451552798833e + 59
...

该表显示,这些值应该是:
甲烷 97.25
乙烷 426.50
丙烷 2755.60
2-甲基丙烷 3390.25
丁烷 10906.60
...

如何正确读取这些数字?

我的代码可以在这里找到

原始文件和结果文件在这里这里

如果您在访问文件时遇到问题,请告诉我!

PS我已经尝试根据结构文档更改格式字符串以包含“>”符号 - 这仍然会导致意外值以及一些NaN!

python floating-point binary struct python-3.x

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

嵌套UICollectionViews的问题

我有2个嵌套的UICollectionViews.外部集合视图的委托是主视图控制器,内部集合视图委托是外部集合视图的UICollectionCell.

外部集合视图只有一个标签和内部集合视图 - 通常会有七个,内部集合视图应包含3或4个单元格(包含3个标签).

问题是内部集合视图似乎只是在重复之后才更新两次(对于外部视图中的前两组数据).

这是外部UICollectionView的cellForItemAtIndexPath

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Main Tide Data Table Cell";

    TideDataTableCell* tideDayDataCell = [self.tideDataTable dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    tideDayDataCell.tideDataTable.delegate = tideDayDataCell;
    tideDayDataCell.tideDataTable.dataSource = tideDayDataCell;
    tidalDate* tideDate = self.tidalDates[indexPath.row];
    tideDayDataCell.thisTidalDate = tideDate;
    tideDayDataCell.dayLabel.text = tideDate.dateString;
    tideDayDataCell.averageTideHeight = self.avgTideHeight;

    tideDayDataCell.backgroundColor = [UIColor whiteColor];
    self.tideDataTable.backgroundColor = [UIColor lightGrayColor];
    return tideDayDataCell;
}
Run Code Online (Sandbox Code Playgroud)

...这里是第二个UICollectionView的cellForItemAtIndexPath,它位于UICollection视图的UICollectionViewCell对象中!

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSString* CellIdentifier = @"Tide Info Table Cell";

    TidalTideTableCell* tidalTideTableCell = [self.tideDataTable dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
    tidalTideTableCell.timeTideLabel.text …
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview uicollectionviewcell

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