小编Uma*_*zal的帖子

如何在BottomSheetDialog android的顶部中心添加关闭按钮?

想要在 BottomSheetDialog 上添加关闭按钮来关闭它。

我正在使用 BottomSheetDialog 的自定义视图(Linearlayout)。

filterDialog = new BottomSheetDialog(context); filterDialog.setContentView(rootView); filterDialog.getWindow().setWindowAnimations(R.style.CustomDialogAnimation); filterDialog.show();

下图是我的过滤器对话框:

在此输入图像描述

这就是我想要实现的目标:

在此输入图像描述

任何帮助将不胜感激。

android android-alertdialog bottom-sheet

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

Alamofire火变量类型没有下标成员

在更新到Alamofire 4并将我的代码更新为Swift 3后,我的所有请求都因某些原因无效.我尝试使用的变量以红色突出显示并说"Type Any'没有下标成员"

这是我的代码:

    Alamofire.request("https://example.com/notifications.php?action=\(action)&UUID=\(UniversalUUID)&token=\(token)").responseJSON{ (response) -> Void in

      if let JSON = response.result.value{
     let message = JSON["message"] as! String

    print(message)

}
Run Code Online (Sandbox Code Playgroud)

ios swift alamofire swift3

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

是否可以在将通用应用程序上传到应用程序商店后将其更改为iphone?

我正在尝试上传我的应用程序的新版本,该版本仅兼容iphone.之前它被上传为通用应用程序.是否可以在下次上传到App Store时禁用IPAD兼容性?

有人对此有所了解吗?

iphone xcode itunesconnect ios

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

以编程方式更改视图的高度和宽度会导致使用swift在iOS中出现意外行为

我正在通过使用圆形视图

dashboardView.layer.cornerRadius = dashboardView.frame.height/2
Run Code Online (Sandbox Code Playgroud)

它工作正常.然后我用这种方法改变了View的高度和宽度

dashboardView.frame = CGRect(x: screenSize.width/2,y: 300,width: 200,height: 200)
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试使用相同的方法进行循环时,它不起作用.我还使用此方法在视图上添加了渐变图层

    let gradient: CAGradientLayer = CAGradientLayer()
    let endingColorOFGradient = UIColor(colorLiteralRed: 133/255, green: 210/255, blue: 230/255, alpha: 1.0).CGColor
    let startingColorOfGradient = UIColor(colorLiteralRed: 50/255, green: 189/255, blue: 170/255, alpha: 1.0).CGColor
    gradient.startPoint = CGPoint(x: 1.0, y: 0.5)
    gradient.endPoint = CGPoint(x: 0.0, y: 0.5)
    gradient.frame = CGRect(x: 0, y: 0, width: dashboardView.layer.frame.width, height: dashboardView.layer.frame.height)
    gradient.colors = [startingColorOfGradient , endingColorOFGradient]
    self.dashboardView.layer.insertSublayer(gradient, atIndex:0)
    // making gradient round
    gradient.cornerRadius = dashboardView.frame.height/2
Run Code Online (Sandbox Code Playgroud)

在更改View渐变的大小后,图层确实变圆,但我的视图不会.

这是我创建的视图.实际上我想根据设备改变它的大小.在iphone 5上它应该很小,在iphone 6+上应该更大 …

gradient frame uiview ios swift

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

将swift 2.x转换为swift 3问题

我已经使这个功能得到了每一天的所有步骤,但是我想将这个函数从swift 2.x转换为swift 3.但是我被困在两个不同的点上.

let anchorDate = calendar.dateComponents(anchorComponents)  
Run Code Online (Sandbox Code Playgroud)

我收到此错误:无法使用列表类型的参数(Datecomponents)调用dateCompontents


在这一点上:

let stepsQuery = HKStatisticsCollectionQuery(quantityType: HKQuantityType, quantitySamplePredicate: nil, options: .CumulativeSum, anchorDate: anchorComponents!, intervalComponents: interval)
Run Code Online (Sandbox Code Playgroud)

错误:无法将HKQuantityType.Type类型的值转换为预期的参数类型HKQuantityType.


完整的功能:

func getDailySteps(){
            let calendar = NSCalendar.current
            let interval = NSDateComponents()
            interval.day = 1

        var anchorComponents = calendar.dateComponents([.day , .month , .year], from: NSDate() as Date)
        anchorComponents.hour = 0
        let anchorDate = calendar.dateComponents(anchorComponents)

        // Define 1-day intervals starting from 0:00
        let stepsQuery = HKStatisticsCollectionQuery(quantityType: HKQuantityType, quantitySamplePredicate: nil, options: .CumulativeSum, anchorDate: anchorComponents!, intervalComponents: interval)

        // Set …
Run Code Online (Sandbox Code Playgroud)

ios swift swift3

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

如何在按钮边界外禁用TouchUpInside Action

这是我的Xib.我只是拖了一个UIButton并改变了它的背景颜色.

在此输入图像描述

我使用此代码创建了一个半圆图层

    let circlePath = UIBezierPath.init(arcCenter: CGPointMake(mybutton.bounds.size.width / 4, 0), radius: mybutton.bounds.size.height, startAngle: 0.0, endAngle: CGFloat(M_PI), clockwise: true)
    let circleShape = CAShapeLayer()
    circleShape.path = circlePath.CGPath
    mybutton.layer.mask = circleShape
Run Code Online (Sandbox Code Playgroud)

这是我的输出.

在此输入图像描述

它完美,因为我想要它.但问题是这个按钮可以在其圆形区域外点击(根据按钮的实际形状).我希望它只能作为圆形可点击.

我怎样才能做到这一点?谢谢.

cashapelayer ios uibezierpath swift

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

如何在swift中比较NSDATA字节

我从这里得到文件大小:

 let docummentdata: NSData = NSFileManager.defaultManager().contentsAtPath(path)!
Run Code Online (Sandbox Code Playgroud)

现在我想要的是docummentdata大小是否大于10MB.我想做点什么,还有别的什么.我试过这样做:

 var result: Int = Int(docummentdata.length)
Run Code Online (Sandbox Code Playgroud)

并做到了

   if docummentdata.length < 1e+7{
       print("compared") 
     }
else
{ print("not compared")
}
Run Code Online (Sandbox Code Playgroud)

我得到了这样的东西

二元运算符<不能应用于Int和Double类型的操作数 如何比较字节和执行程序?

nsdata ios swift

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