小编Chi*_*jar的帖子

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

如何在集合视图中单选单元格?

这是代码正常工作,但当我将滚动我的集合视图,然后另一个单元格也被选中,例如18个图像可用,并在运行时首先显示六个,当我将选择任何一个六个然后也选择另一个2单元格我在这里混淆为什么已选择另外两个单元格请给我解决方案

在此输入图像描述

在这里,我在主要展示故事板上采取了6个单元格

UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout*)self.collectionView.collectionViewLayout;

flowLayout.minimumLineSpacing = 15;
CGFloat availableWidthForCells = CGRectGetWidth(self.collectionView.frame) - flowLayout.sectionInset.left - flowLayout.sectionInset.right - flowLayout.minimumInteritemSpacing *2;

cellWidth = availableWidthForCells /6;
    NSLog(@"cellWidth:%f",cellWidth);
flowLayout.itemSize = CGSizeMake(cellWidth, cellWidth);
Run Code Online (Sandbox Code Playgroud)

这是我的Didselect和didDeselect方法

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    UICollectionViewCell* cell = [collectionView cellForItemAtIndexPath:indexPath];

    cell.layer.cornerRadius = cellWidth / 2.0;
    cell.layer.backgroundColor = [UIColor blackColor].CGColor;
    NSLog(@"INDEXPATH:-%ld",(long)indexPath.row);
}
-(void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath{

    UICollectionViewCell* cell = [collectionView cellForItemAtIndexPath:indexPath];
    cell.layer.cornerRadius = cellWidth / 2.0;
    cell.layer.backgroundColor = [UIColor whiteColor].CGColor;

}
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview

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

在 Flutter 中创建弹出对话框

我需要一种在颤动中创建弹出对话框的方法。

在此输入图像描述

我能够根据需要创建“双色调”设计和一个对话框,但是当用户单击按钮导航到此屏幕时,我无法找到弹出对话框的方法。

创建视图的代码:

class CreateID extends StatelessWidget {
  const CreateID({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: cPrimaryColor,
      body: SafeArea(
        child: Column(
          children: [
            Expanded(
              child: Container(
                width: double.infinity,
              ),
            ),
            Expanded(
              child: Container(
                width: double.infinity,
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(20.0),
                    topRight: Radius.circular(20.0)
                  )
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

这是该对话框的代码:

class PopUp extends StatelessWidget {
const PopUp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold( …
Run Code Online (Sandbox Code Playgroud)

dialog popup flutter

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