小编Ade*_*eel的帖子

Git 不跟踪文件夹中的文件 - 来自 .xcassets 的 contents.json

我已经检查了几乎所有关于 SO 的问题,但没有任何对我有用。我无法提交任何Contents.json文件的问题.xcassets。每当我向.xcassets源代码控制添加新图像时,都会列出图像而不是Contents.json文件。我正在使用一个 bitbucket 存储库,甚至没有SourceTree在未提交的更改中显示此文件。甚至尝试通过终端添加所有文件。

git add --all
Run Code Online (Sandbox Code Playgroud)

任何猜测为什么会发生这种情况以及可能的解决方案是什么?

更新:.gitignore文件类似于:

ProjectName.xcworkspace/xcuserdata
ProjectName.xcodeproj/xcuserdata
*.xcscheme
xcschememanagement.plist
Run Code Online (Sandbox Code Playgroud)

而且.git/info/exclude看起来是这样的:

.DS_Store
UserInterfaceState.xcuserstate
Run Code Online (Sandbox Code Playgroud)

git xcode xcasset sourcetree

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

在iOS UIAlertController中,我们可以保留UIAlertAction的对齐文本

我需要实现一个UIAlertController,如UIAlertController左边的allignedUIAlertAction

说明1

在互联网上搜索了很多,然后在stackoverflow中,我能够实现左对齐的标题 UIAlertController

内容描述2

但是如何左对齐UIAlertAction的文字呢?

任何帮助/线索都会非常有帮助.

text alignment ios uialertaction

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

如何将Table dataSource和委托出口链接到UITableViewController?

我是Swift/iOS开发的新手.

我有一个UITableView在我的storyboard,我想用一些数据来填充.在我尝试这样做的过程中,我创建了一个继承自的类UITableViewController.实施还没有完成,但我的理解是,从这个类继承,我可以提供一个IBOutlet到两个dataSourcedelegate.

当我尝试将插座拖动到源文件中时,我没有得到我之前测试时的插入点.见下图: 没有插入线! :(

我该怎么做才能将此类定义为UITableView?的处理程序?

storyboard uitableview ios uistoryboard swift

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

带有多个部分的水平滚动的collectionview

我想像这样开发屏幕(目标C): 在此输入图像描述

在这里有部分名称:

  1. 我们喜爱的新游戏
  2. 我们喜爱的新应用

两者都具有水平滚动并且彼此独立.

我的问题是我应该用什么方法从以下两个选项中实现这个.如果有的话,请提供任何参考样本:

  1. 我可以用单个UICollectionView和不同的部分(动态)实现相同的行为.但不同部分的滚动应该是独立的.因为第1部分可能有不同数量的项目(行),第2部分可能有不同数量的项目(行)
  2. 我是否必须以编程方式获取多个collectionview,然后在uiscrollview(垂直scrollview)中插入.然后,abd定义水平滚动并通过分页集合视图添加单元格中的项目.

我目前通过下面的代码完成了水平滚动的集合视图:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
    _collectionView=[[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layout];
    [_collectionView setDataSource:self];
    [_collectionView setDelegate:self];

    [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
    [_collectionView setBackgroundColor:[UIColor redColor]];

    [self.view addSubview:_collectionView];

    // Do any additional setup after loading the view, typically from a nib.
}

#pragma mark Collection View Methods

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 15;
}

// The cell that is returned must be retrieved …
Run Code Online (Sandbox Code Playgroud)

iphone ios uicollectionview uicollectionviewcell

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

Swift - 特定长度的子数组

我有一个数组可以说[1, 2, 3, 4]。我必须检查一个元素或元素的任意组合的总和是否等于特定数字。

例子

  1. 51 + 4 = 52 + 3 = 5
  2. 61 + 2 + 3 = 62 + 4 = 6

一种方法可能是创建数组的幂集,如本答案所示,然后循环迭代它。但这不是一个好主意,因为如果元素数量n增加,幂集将变得内存庞大。就此而言,更好的方法是创建特定长度的子集/子数组并逐个迭代它们。

可以说k是子数组的长度

  • k = 2应该给我[[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]
  • k = 3应该给我[[1, 2, 3], [1, 2, 4], [2, 3, 4]]

现在的问题是,我将如何创建如上所述的特定长度的子数组/子集?

arrays algorithm sub-array ios swift

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

使用 UIView 作为子视图的具有水平分页的 UIScrollView

我已经看到了以下问题的答案。我是 swift 编程的新手,我正在尝试实现类似的功能。我只是想知道您是否对如何在 swift 3 Xcode 8 中实现这一点有任何指导。我一直在寻找合适的解决方案,但我没有运气。

我正在尝试使用 UIViews 作为 UIscrollviews 的子视图。我还想让每个视图在按下时填满屏幕并显示另一个 UIView。我在 'Tyler the Creator' 的 GOLF 应用程序上看到了类似的功能

我正在尝试实现的功能如下图所示。

您能提供的任何帮助将不胜感激。

这是我正在尝试创建的功能的表示。

图片

uiscrollview uiview ios subviews swift3

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

编辑时重置 UITableViewCell 的角半径

我有一个 UITableView,它有一个带有自定义圆角半径的 UITableViewCells 列表。滑动编辑时,ei 删除/插入,圆角半径重置为 0。

正在重置单元格角半径的图像

我试图在编辑时设置角半径:

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
    guard let cell = tableView.cellForRow(at: indexPath) as? HabitTableViewCell else { return }
    cell.layer.cornerRadius = 13
    if editingStyle == .delete {
        controller.delete(habit: frc.object(at: indexPath))
    }
}
Run Code Online (Sandbox Code Playgroud)

我也尝试过以类似的方式实现 willBeginEditingRowAt 以尝试使拐角半径保持不变。我尝试的最后一件事是在 trailingSwipeActionsConfigurationForRowAt 中创建自定义 UIContextualAction,但它不会改变任何东西。

大约四年前有人问类似的问题,但一直没有找到最终的解决方案。任何帮助或见解表示赞赏!

xcode cornerradius uitableview ios swift

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

如何在 Swift 中向集合视图添加边框?

不是集合视图单元格,我通过在 ViewController 中应用特定的边框函数(例如 borderColor 和cornerRadius 方法)来解决这个问题。我说的是用一个边框封装单元格的整个视图,有点像这样:

我想要实现的集合视图单元格

非常感激。

ios swift

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