A我有一个包含两个目标(和)的框架,B其文件结构如下:
FooFramework
|__ A
|__ Foo.swift
|__ Bar.swift
|__ Foobar.swift
|__ B
|__ Barfoo.swift
Run Code Online (Sandbox Code Playgroud)
BA基本上有的源的子集(其中B被设置为目标),例如B仅使用Foo.swift和Bar.swift,但不使用Foobar.swift。
现在我有一个应用程序需要框架A和B(在单独的目标中)。
此时我不确定如何设置Package.swift文件以使此设置起作用。每当我打开Package.swiftinXcode并尝试构建框架时B,编译器都会抱怨 in 中缺少类型Barfoo.swift,因为它们包含在Bar.swift.
这就是我设置Package.swift文件的方式:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "Framework",
platforms: [
.iOS(.v11),
.macOS(.v10_15)
],
products: [
.library(
name: "A",
targets: ["A"]),
.library(
name: "B",
targets: ["B"]), …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的应用创建一些自定义通知。
通常,合拢视图布局限制为64 dp,展开视图布局限制为256 dp。
尽管我考虑了这些限制,但是您似乎可以在下面的屏幕快照中看到在几部手机上都没有收到通知。我对此进行了一些研究,因为我认为根据不同的制造商或用户界面也存在一些限制,但找不到任何东西。
就是这样实现的:
// 64dp is set for height
val collapsedView = RemoteViews(packageName, R.layout.custom_notification_collapsed)
// 256dp is set for height
val expandedView = RemoteViews(packageName, R.layout.custom_notification_expanded)
val customNotification: Notification = NotificationCompat.Builder(this, "default")
.setSmallIcon(R.drawable.ic_launcher_background)
.addAction(R.drawable.ic_map, "Personal", PendingIntent.getService(this, 0, personalIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.addAction(R.drawable.ic_map, "Business", PendingIntent.getService(this, 0, businessIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.addAction(R.drawable.ic_map, "Work", PendingIntent.getService(this, 0, businessIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.setColor(Color.parseColor("#00D8FF"))
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(collapsedView)
.setCustomBigContentView(expandedView)
.build()
notificationManager.notify(4, customNotification)
Run Code Online (Sandbox Code Playgroud)
结果如下:
现在的问题是:我是否以某种方式使实施失败?如果没有,有没有办法找出最大值。以编程方式通知当前手机的通知高度?