小编Tob*_*aut的帖子

如何使用 SwiftUI 实现具有样式、文本和图标的可重用按钮?

我知道习俗是如何ButtonStyle运作的。但我确实想要一个完全可重用的自定义按钮。

又名带有文本和图标的按钮,应用了一些样式。

我知道如何使用带有文本属性的 ButtonStyle 来实现此目的,但我认为这完全是对按钮样式的滥用。

但我不想HStack在我的应用程序中复制具有大内容的按钮。

对于此类用例,您有什么建议?Button网上似乎没有人在 SwiftUI 中对 a 进行子类化。

ios swift swiftui

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

将一行作为选择指示符添加到Swift中的UITabbarItem

我想在UITabbarItems底部使用粗线作为选择指示器.由于应用程序必须适用于不同的手机尺寸,我无法使用图像作为选择指示器.这就是为什么我认为我必须使用Swift来做到这一点.(该行必须是页面宽度的1/3).

我尝试使用UITabBarItem.appearance()但没有成功.

uitabbaritem uitabbar swift

10
推荐指数
4
解决办法
6158
查看次数

如何将Windows 10 IoT(Rasp Pi映像)部署为虚拟机

是否可以使用VirtualBox或VMWare Player将Windows 10 IoT(Rasp Pi映像)部署为虚拟机?

我需要一个测试实验室,一个由三到五个Windows 10 IoT设备组成的网络.虚拟集群将是完美的.我的基于Google和Bing的研究失败了.

问题可能是非ISO磁盘映像文件格式或操作系统的非x86架构,不是吗?

windows iot windows-10

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

Microsoft Teams 选项卡在添加到频道期间无法保存设置

语境:

我尝试编写一个简单的 Microsoft Teams 选项卡来显示源列表。我可以将我的选项卡侧面加载到 Teams 并从频道“+”菜单中选择它。

问题:

如果我想保存我的设置,则会出现一条错误文本,显示“我们无法保存您的选项卡设置。请重试。” 我的浏览器的 javascript 错误控制台中没有错误。

我的 config.html 选项卡 JavaScript 代码:

<script type="text/javascript">
    microsoftTeams.initialize();
    microsoftTeams.settings.registerOnSaveHandler(function (saveEvent) {

        microsoftTeams.settings.setSettings({
            entityId: "example",
            contentUrl: "https://example.com/tab.html",
            suggestedDisplayName: "example",
            websiteUrl: "https://example.com",
            removeUrl: "https://example.com/remove.html"
        });

        saveEvent.notifySuccess();
    });

    function onClick() 
    {
        microsoftTeams.settings.setValidityState(true);
    }
</script>
Run Code Online (Sandbox Code Playgroud)

我的清单.json

{
  "$schema": "https://statics.teams.microsoft.com/sdk/v0.4/manifest/MicrosoftTeams.schema.json",
  "manifestVersion": "0.4",
  "id": "ee90834a-d649-458d-a4e2-0b0f8d425c11",
  "version": "1.0",
  "name": "WINSider Community Deutschland",
  "developer": {
      "name": "WINSider Community Deutschland",   
      "websiteUrl": "https://windowscommunity.de",
      "privacyUrl": "https://windowscommunity.de/de/impressum/",
      "termsOfUseUrl": "http://windowscommunity.de/de/impressum/"
  },
  "tabs" : [{
    "id": "ee90834a-d649-458d-a4e2-0b0f8d425c11",
    "name": "WINSider Community",
    "description" : …
Run Code Online (Sandbox Code Playgroud)

javascript microsoft-teams

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

Xcode 在源文件中向上滚动时崩溃(13 和 14)

我每周都会遇到这种行为很多次。如果我尝试在源文件中向上滚动(随着时间的推移不同的文件),Xcode 会显示死亡沙滩球,直到我强制退出它。

我检查以下内容:

  • 它似乎只发生在 Xcode 文件中,而不是 Objc 文件中,但它可能是一个错误的朋友
  • Xcode 13 和 Xcode 14 beta 1-4
  • 独立于 UIKit 或 SwiftUI 文件
  • 有足够的内存
  • 崩溃期间没有运行构建阶段
  • 该应用程序未运行
  • 文件不在 Dropbox 或 iCloud Drive 等同步文件夹中

您是否也经历过这种行为?您知道如何修复它吗?我失去了很多时间...

ide crash xcode ios

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

如何在 Compose 中使用 Google 地图标记的自定义图标?

问题 如果我使用以下帮助程序/扩展,我将得到一个异常IBitmapDescriptorFactory is not initialized

我检查了 Stackoverflow,其中一些人建议创建工厂的本地属性并分配它,但这也不起作用。

Android Studio 在右侧显示了图标,因此我认为资产已正确添加。

来源

fun Webcam.toMarkerOptions(): MarkerOptions {

    return MarkerOptions()
        .title(name)
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_map_webcam))
        .position(coordinate.toLngLat())
}
Run Code Online (Sandbox Code Playgroud)

源 2 也崩溃了

fun MarkerOptions.icon(context: Context, @DrawableRes vectorDrawable: Int): MarkerOptions {
    this.icon(ContextCompat.getDrawable(context, vectorDrawable)?.run {
        setBounds(0, 0, intrinsicWidth, intrinsicHeight)
        val bitmap = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888)
        draw(Canvas(bitmap))
        BitmapDescriptorFactory.fromBitmap(bitmap)
    })
    return this
}
Run Code Online (Sandbox Code Playgroud)

android google-maps-markers kotlin

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

寻找 Jetpack Compose YouTube 视频播放器包装依赖项

介绍

我是 Jetpack Compose 的新手,对我来说,在第一次尝试时理解或让所有内容都正确并不容易。

这就是为什么我喜欢查看其他人的开源工作以更好地理解该主题。

问题

我当前的问题是我必须将 YouTube 视频嵌入到我的应用程序中。起初,我以为我使用的是嵌入式 Web 视图,但是嘿,我是本机应用程序开发人员,让我们以本机方式来做吧!

但我跌倒了很多

  1. 我们作为开发人员必须使用 Google 的本地 *.jar 文件来嵌入视频播放器,这是真的吗?
  2. 确实没有官方的 Jetpack Compose 组件吗?
  3. 我们那里确实没有提供此类功能的依赖项吗?
  4. 是的,我在问之前就搜索过

这就是为什么如果你们中有人能指出正确的方向,让我的小型自学应用程序取得任何进展,那就太棒了。

android kotlin youtubeplayer android-jetpack-compose

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

使用Swift在启动屏幕上显示应用程序版本

脚本

我想展示使用Swift制作的iOS 9应用程序的版本.

我做了什么

我知道如何获得版本(let version: String = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String)

我的主屏幕上也有自定义标签.

我的问题

我现在的问题是,不允许在启动/启动屏幕上使用自己的UIViewController.

许多应用程序在该屏幕上显示其版本.这就是为什么我认为必须有一种方法来做到这一点.

uiviewcontroller ios swift launch-screen

5
推荐指数
3
解决办法
5587
查看次数

按代码设置WKInterfaceImage的(边界)半径

我必须WKInterfaceImage通过Swift代码设置a的radius属性.

我需要与我的其他UIImageViews相同的格式:

logoView.layer.cornerRadius = logoView.frame.width / 2
    logoView.clipsToBounds = true
    logoView.layer.borderWidth = 1.0
    logoView.layer.borderColor = UIColor (
                                    red: 0x33 / 255,
                                    green: 0x99 / 255,
                                    blue: 0x66 / 255,
                                    alpha: 1.0
                                ).CGColor
Run Code Online (Sandbox Code Playgroud)

我检查了参考指南,但我找不到解决方案.谢谢你的帮助!

ios swift watchkit wkinterfaceimage

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

如何使用一个动态高度行创建3行Flutter布局

我目前在Flutter中创建基本的3行式页面布局时遇到问题。

其中两行应具有固定的高度,其余一行应采用页面的其余高度。

合适的Widget结构是什么?我想那Expanded应该是它的一部分吗?

伪XAML

<RowDefinitions>
    <RowDefinition Height="50" />
    <RowDefinition Height="*" />
    <RowDefinition Height="75" />
</RowDefinition>
Run Code Online (Sandbox Code Playgroud)

线框

线框

当前状态

  // Gets the fixed top column.
  static Row _topBackgroundColumn = new Row(
    children: <Widget>[
      Padding(
        padding: EdgeInsets.all(20),
        child: Image(
            image: AssetImage("assets/animation-bird-1.png"),
            height: 50,
            alignment: AlignmentDirectional.topStart,
        )
      )
    ],
  );

  static Container _contentContainer = new Container(
    alignment: Alignment.center,
    child: Center(
      child: Text("bla")
    ),
  );

  // Gets the fixed, image-heavy bottom column.
  static Container _bottomBackgroundColumn = new Container(
    child:
      Image(
        image: AssetImage("assets/background-bottom.png"),
        repeat: …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

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

如何在 Jetpack Compose 中将 NavigationRail 的内容居中(缺少 menuGravity)

问题

在某些文档中,可组合项androidx.compose.material.NavigationRail具有可选的“居中”对齐方式。我无法使用 Jetpack Compose 实现此目的。

“旧”XML 属性是app:menuGravity="center" 根据本教程的

我尝试过但没有成功的事情

我尝试将 NavigationRail(实际小部件的简单包装器)放入具有对齐设置的 Box 中:

Box(contentAlignment = Alignment.Center) {
    NavigationRail(
        selectedItem = selectedItem,
        onSelectItem = { selectedItem = it }
    )
}
Run Code Online (Sandbox Code Playgroud)

并将其直接放入原始可组合项中:

NavigationRail(
    modifier = modifier.width(80.dp),
    backgroundColor = MaterialTheme.colors.surface
) {
   Box(contentAlignment = Alignment.Center) {
       for (item in NavigationItem.values()) {
      NavigationRailItem(
          selected = selectedItem == item,
          onClick = { onSelectItem.invoke(item) },
          icon = { Icon(item.icon, item.title) },
          alwaysShowLabel = true,
          selectedContentColor = MaterialTheme.colors.primaryVariant,
          unselectedContentColor = MaterialTheme.colors.primary,
          label …
Run Code Online (Sandbox Code Playgroud)

android kotlin material-design android-jetpack-compose

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

'NSInvalidArgumentException',原因:' - [UIImageView _isResizable]自定义tableview单元格的异常

我从NSInvalidArgumentException自定义单元格中获得执行时间.

调试器错误日志:

2014-12-25 21:39:11.397 Codebuddies[24159:11353215] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView _isResizable]: unrecognized selector sent to instance 0x7fa5f580b6a0' `

相关的swift代码块:

let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as FeedTableViewCell

我已经检查了什么:

  • 单元格的标识符设置为"单元格"

感谢帮助!

uitableview swift

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

Flutter 的 TextPainter 抛出一个 '!_needsLayout': is not true。例外

我尝试使用 aTextPainter来获取 Text Widget 中字符串的最大长度,但是如果我调用 Painter,它会抛出!_needsLayout': is not true.异常。

例外

The following assertion was thrown building FeedPage(dirty, dependencies: [MediaQuery], state: _FeedPageState#9c489):
'package:flutter/src/painting/text_painter.dart': Failed assertion: line 546 pos 12: '!_needsLayout': is not true.
Run Code Online (Sandbox Code Playgroud)

使用 TextPainter 的方法

int maxCharCountToFit(String content) {
    List<String> splitted = content.split(" ");

    for (int i = splitted.length; i >= 0; i--) {
      bool retry = TextPainter(
            text: TextSpan(text: splitted.sublist(0, splitted.length - i).join(" "), style: pageTextStyle),
            maxLines: 25,
            textScaleFactor: MediaQuery.of(context).textScaleFactor,
            textDirection: TextDirection.ltr,
          ).didExceedMaxLines ==
          false; …
Run Code Online (Sandbox Code Playgroud)

android dart flutter flutter-android

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