小编Dec*_*nna的帖子

更改xml drawable图标的颜色

有没有办法将颜色设置为可绘制的图标?那么图标的颜色会被我的自定义颜色覆盖?

 <item android:drawable="@drawable/icon1"
  //set color to my icon here
    android:state_pressed="true" />
<item android:drawable="@drawable/icon2"
  //set color to my icon here
  />
Run Code Online (Sandbox Code Playgroud)

android android-xml

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

在Objective C中设置静态变量

我似乎无法找到一种方法来设置我创建的静态int,以便为保存到持久内存的每个对象分配唯一ID.下面给出了一个'no setter方法'setIdGen'用于赋值给属性.

-(void)viewDidLoad
{
    PlayerMenuController.idGen = [[NSUserDefaults standardUserDefaults] floatForKey:@"idGen"];
}
Run Code Online (Sandbox Code Playgroud)

除了以上内容之外,我还尝试创建一个静态setIdGen方法,该方法将返回错误的访问错误,并使用自己的set方法创建NSIntegers.当我尝试使用=分配它时,我的静态NSMutableArray给出了相同的错误,但在使用setArray时工作正常.

idGen方法:

+ (int) idGen
{
    /*static int idGen;
    if(!idGen)
    {
        idGen = 0;
        NSLog(@"idGen reset");
    }*/
    return self.idGen;
}
Run Code Online (Sandbox Code Playgroud)

iphone variables static objective-c ios

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

如何更改我的配置文件?

我今天想添加一个新的 Beta 测试人员,因此更新了我的配置文件以包含它们。当我尝试运行我的应用程序时,出现错误,提示我的个人资料“*”与我的个人资料“com.HUDKING”不匹配。我删除了旧的配置文件和捆绑包标识符,以检查这不是原因,并更改了我的协同设计,如下所示。

当我尝试存档我的应​​用程序时,出现以下错误: 找不到配置文件“259FB85E-9614-4A3A-9987-9F4619BA2F9B”

我的个人资料似乎都没有此标识符,我已手动设置它们以确保选择正确的个人资料: 在此输入图像描述

我该如何解决?有没有更简单的方法来运行 Beta 测试?

xcode adhoc ad-hoc-distribution ios provisioning-profile

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

How to tell what queue a completionHandler executes on?

查看文档URLSession.dataTask很明显这个函数是异步调用的,但没有提到 completionHandler 是否返回到主线程、调用它的线程或保留在执行 dataTaskOperation 的线程上。

这里有一个普遍的约定吗?

  let task = URLSession.shared().dataTask(with: request) {
        //What Thread are we on here?
    }
Run Code Online (Sandbox Code Playgroud)

asynchronous grand-central-dispatch ios completionhandler swift

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

Swift 的 String.count 的主要内容是什么?

当 swift 使用String.count它时:

O(n)每次我们调用它时,我们都会遍历整个 String 以对其进行计数

或者

O(1)其中 swift 之前存储了这个数组的大小并简单地访问它。

arrays big-o swift

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

如何为iOS 10启用通知?

在iOS9中,我们提示用户是否需要通知并将其引导至设置页面,以便他们可以为我们的应用启用通知权限.但是,如下所示,没有选项可以在iOS 10中的我的应用程序权限设置中启用通知.是否有一个新进程,我必须使用适当的权限填充此列表?

在此输入图像描述

//check the notifications status. First the global settings of the device, then our stored settings
func checkGlobalNotifications() {
    let grantedSettings = UIApplication.sharedApplication().currentUserNotificationSettings()
    if grantedSettings!.types.rawValue & UIUserNotificationType.Alert.rawValue != 0 {
        globalNotificationsEnabled = true
        //if global notifications are on, then check our stored settings (user)
        if CallIn.Settings.notificationsEnabled { notificationsOn() } else { notificationsOff() }
    }
    else {
        globalNotificationsEnabled = false
        //global notifications (iOS) not allowed by the user so disable them
        notificationsOff()
    }
}
Run Code Online (Sandbox Code Playgroud)

notifications ios swift ios10

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

如何在不降低编译器速度的情况下合并多个数组?

添加这行代码会导致编译时间从10秒增加到3分钟.

var resultsArray = hashTagParticipantCodes + prefixParticipantCodes + asterixParticipantCodes + attPrefixParticipantCodes + attURLParticipantCodes
Run Code Online (Sandbox Code Playgroud)

将其更改为此会使编译时间恢复正常.

var resultsArray = hashTagParticipantCodes
resultsArray += prefixParticipantCodes
resultsArray += asterixParticipantCodes
resultsArray += attPrefixParticipantCodes
resultsArray += attURLParticipantCodes
Run Code Online (Sandbox Code Playgroud)

为什么第一行导致我的编译时间如此急剧减慢并且有一种更优雅的方式来合并这些数组而不是我发布的5行解决方案?

arrays compilation ios swift

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

如何在 git 上共享 Xcode 性能测试基线?

我在 Xcode 上进行了性能测试,基线设置如下所示。 在此处输入图片说明

这些基线似乎是本地保存的(如断点),因此我对它们的更改不会通过 git 传输。当我以外的任何人运行我的性能测试并且他们太慢时,测试不会失败。我该如何解决这个问题?

git xcode performance-testing ios xcode8

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

在xib文件中在TableViewCell中显示可变数量图像的最佳方法是什么?

我正在构建一个关于会议的应用程序,我希望在每个会议单元中显示VIP参与者的预览.

这些参与者不可点击也不可滚动,唯一目的就是快速查看它们.

问题是视图非常动态:

  • VIP显示图像或缩写
  • 其余与会者只是一个数字
  • 如果超过5个VIP,则圆圈开始重叠(间距变小)
  • 如果9名贵宾,大包装圈"所有出席的贵宾"

这是它的样子: 在此输入图像描述

我该怎么办?

  • CollectionView(因为我对图像的任何交互都不感兴趣,所以看起来过度杀戮)?
  • StackView?
  • 图像(并以编程方式更改约束)?

注意:

这只是一种Table View Cell,但我们有很多变化,所以我们在xib文件中构建自定义单元格.Xcode不允许我将集合视图单元格添加到xib中的集合视图中.

在此输入图像描述

uitableview ios uicollectionviewcell swift uistackview

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

为什么不调用UICollectionView insetForSectionsAtIndex?

我正在寻找使用以下功能的方法,但不幸的是它并未被调用。

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlowLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
        let cellCount = Double(collectionView.numberOfItems(inSection: section))
        if let cell = collectionView.cellForItem(at: IndexPath(row: 0, section: section))
        {
            let cellWidth = Double(cell.frame.size.width)
            let totalCellWidth = cellWidth * cellCount
            let cellSpacing = Double(collectionViewLayout.minimumInteritemSpacing)
            let totalSpacingWidth = cellSpacing * (cellCount - 1)

            let leftInset = (collectionView.frame.width - CGFloat(totalCellWidth + totalSpacingWidth)) / 2
            let rightInset = leftInset

            return UIEdgeInsetsMake(0, leftInset, 0, rightInset)
        }

    return collectionView.layoutMargins
}
Run Code Online (Sandbox Code Playgroud)

我收到以下控制台错误,但是我的单元格小于我的collectionView,并且将节插图和布局边距设置为0。

2017-03-30 11:25:14.624 Prep [92400:1862856]未定义UICollectionViewFlowLayout的行为,因为:2017-03-30 11:25:14.624 Prep …

uicollectionview swift

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