小编Tol*_*lar的帖子

在swift中为背景添加模糊效果

我正在设置背景图像来查看控制器.但我也想在这个背景下添加模糊效果.我怎样才能做到这一点?

我用以下代码设置背景:

self.view.backgroundColor = UIColor(patternImage: UIImage(named: "testBg")!)
Run Code Online (Sandbox Code Playgroud)

我发现在互联网上模糊imageview我怎么能实现这个到我的背景?

var darkBlur = UIBlurEffect(style: UIBlurEffectStyle.Dark)
// 2
var blurView = UIVisualEffectView(effect: darkBlur)
blurView.frame = imageView.bounds
// 3
imageView.addSubview(blurView)
Run Code Online (Sandbox Code Playgroud)

ios swift

108
推荐指数
7
解决办法
13万
查看次数

什么是minUptime

我使用永远与我的项目.这些选项有何作用:

  • minUptime
  • spinSleepTime

我从GitHub页面上无法理解.

daemon node.js forever

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

将byte []转换为JsonObject

我想转换byteJsonObject.我试过这样的:

public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
    String testV=new JsonObject(new String(responseBody));
} 
Run Code Online (Sandbox Code Playgroud)

但我收到编译器错误:

JsonObject cannot be applied to java.lang.String
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

java android

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

如何加速木偶操作?

网页有一个按钮,木偶操作者必须尽快单击该按钮,按钮变为可见。此按钮并非始终可见,而是同时对所有人可见。所以我必须不断刷新才能发现按钮变得可见。我写了下面的脚本来做到这一点:

    const browser = await puppeteer.launch({
        headless: true,
        args: ['--no-sandbox']
    });
    const page = await browser.newPage()
    await page.setViewport({ width: 1920, height: 1080})


//I am calling my pageRefresher method here

async function pageRefresher(page,browser, url) {
        try {
            await page.goto(url, {waitUntil: 'networkidle2'})
            try {
                await page.waitForSelector('#ourButton', {timeout: 10});
                await page.click('#ourButton')
                console.log(`clicked!`)
                await browser.close()
            } catch (error) {
                console.log('catch2 ' + counter + ' '  + error)
                counter += 1
                await pageRefresher(page, browser, url)
            }
        }catch (error) {
            console.log('catch3' + error)
            await browser.close(); …
Run Code Online (Sandbox Code Playgroud)

javascript node.js puppeteer

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

功能签名专业化在swift中崩溃

我收到了用户的崩溃报告,但我不了解崩溃报告.

它说:

Ribony: function signature specialization <Arg[0] = Owned To Guaranteed and Exploded, Arg[1] = Owned To Guaranteed and Exploded, Arg[2] = Owned To Guaranteed and Exploded, Arg[3] = Exploded, Arg[4] = Owned To Guaranteed> of Ribony.ChatManager.sendMessage (Ribony.ChatManager)(Swift.String, to : Swift.String, anonClosed : Swift.String, toWeb : Swift.Int) -> () + 3608
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我正在使用swift.这是什么报告?我的sendMessage方法:

func sendMessage(message: String,to: String,anonClosed: String,toWeb: Int) {
        NSNotificationCenter.defaultCenter().postNotificationName(mySpecialNotificationKey, object: self,userInfo:["message":message])
        var sender=""
        var token=""
        var toSubstr=""
        if count(to) >= 5 {
            let rangeOfTo = Range(start: to.startIndex, …
Run Code Online (Sandbox Code Playgroud)

ios swift

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

从片段中获取编辑文本值

我正在使用片段,我在片段中有一个编辑文本,我想在主要活动中获得价值。

\n\n

这是我的片段布局

\n\n
<?xml version="1.0" encoding="utf-8"?>\n<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\n    android:layout_width="match_parent"\n    android:layout_height="match_parent"\n    android:orientation="vertical"\n    android:background="#878787" >\n\n        <TextView android:layout_width="fill_parent"\n        android:layout_height="wrap_content"\n        android:gravity="center"\n        android:text="dfgdfgdf"\n        android:textSize="20dp"\n        android:layout_centerInParent="true"\n        android:id="@+id/user_name"/>\n\n    <EditText\n    android:id="@+id/message"\n    android:layout_width="fill_parent"\n    android:layout_height="wrap_content"\n   />\n\n    <Button \n        android:text="G\xc3\xb6nder"\n        android:layout_width="fill_parent"\n        android:layout_height="wrap_content"\n        android:onClick="getFromUser"\n        android:layout_marginTop="40dp"\n        />\n\n</RelativeLayout>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在使用此函数加载片段:

\n\n
public void startChat(JsonObject user) {\n    FrameLayout layout = (FrameLayout)findViewById(R.id.container);\n    layout.setVisibility(View.VISIBLE); \n    Bundle bundle = new Bundle();\n    bundle.putString("name", user.get("name").getAsString());\n    sendTo=user.get("username").getAsString();\n    FragmentManager fragmentManager = getSupportFragmentManager();\n    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();\n    ConversationFragment conv = new ConversationFragment();\n    conv.setArguments(bundle);\n    fragmentTransaction.add(R.id.container, conv);\n    fragmentTransaction.commit();\n    viewPager.setVisibility(View.GONE);\n    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);\n    actionBar.setDisplayHomeAsUpEnabled(true);\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的片段类

\n\n
public …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

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

使用进度条作为imageview的边框

我想在imageview中添加一个进度条.我尝试使用以下代码:

<de.hdodenhof.circleimageview.CircleImageView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/image"
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="3dp"
    android:src="@drawable/defaultprofile" />
<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:indeterminate="false"
    android:progressDrawable="@drawable/circular_progress_bar"
    android:background="@drawable/circle_shape"
    style="?android:attr/progressBarStyleHorizontal"
    android:max="100"
    android:progress="65"
    android:layout_alignParentTop="true"
    android:layout_alignLeft="@+id/image"
    android:layout_alignStart="@+id/image" />
Run Code Online (Sandbox Code Playgroud)

circular_progress_bar.xml:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="270"
    android:toDegrees="270">
    <shape
        android:innerRadiusRatio="2.5"
        android:shape="ring"
        android:thickness="1dp"
        android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->

        <gradient
            android:angle="0"
            android:endColor="#007DD6"
            android:startColor="#007DD6"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>
Run Code Online (Sandbox Code Playgroud)

circle_shape.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadiusRatio="2.5"
    android:thickness="1dp"
    android:useLevel="false">

    <solid android:color="#CCC" />

</shape>
Run Code Online (Sandbox Code Playgroud)

结果:

在此输入图像描述

我该如何解决?进度条应该看起来像imageview的边框.我必须删除填充.

android

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

与 MVVM 的套接字连接

我正在尝试使用 MVVM 架构构建一个聊天应用程序,但我不知道在哪里放置我的套接字连接类,我需要一个想法或起点等。

单一数据源原则

我正在使用单一数据源的真实原则。举个例子:如果消息从套接字服务器发送到应用程序,我的套接字类应该将其保存到数据库,然后应该使用实时数据将其从数据库提供给观察者(因此它们将是视图模型)。

我的应用程序架构

我的应用程序包含不同的活动(聊天屏幕、对话屏幕等),这些活动将观察我的套接字连接存储库类。此外,如果用户关闭应用程序,我的套接字连接将随应用程序一起终止。我不需要任何后台连接。

我在问什么?

实现此功能的最佳方法是什么:

1) Socket 类应该使用实时数据,因为 activites 会观察到它。所以它应该是一个存储库。2)我的套接字类应该在应用程序打开时始终存在。

我应该为套接字存储库使用什么?服务或单例类或不同的东西?你有什么建议?我应该在哪里启动套接字连接存储库?来自应用程序类还是不同的东西?

java android mvvm

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

Alamofire 5 字典中的任何内容

我正在尝试使用 Alamofire 5 发出发布请求。我必须使用Dictionary<String, Any>参数。因为我正在为 Alamofire 编写一个包装器。但似乎我无法使用字典中的任何对象,因为 Alamofire 给了我一个编译器错误:

Value of protocol type 'Any' cannot conform to 'Encodable'; only struct/enum/class types can conform to protocols
Run Code Online (Sandbox Code Playgroud)

我尝试过的:

    let encodedParameters = Dictionary<String, Any>

    AF.request(url, method: .get, parameters: encodedParameters, headers: headers)
Run Code Online (Sandbox Code Playgroud)

在我的字典中,某些值将是字符串,其他值将是整数。所以我不能使用常量类型。我该如何解决这个问题?

ios swift alamofire

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

在没有推送通知的情况下更改实时活动

我正在尝试在我的应用程序中实现“实时活动”。我正在关注苹果文档。

链接:https ://developer.apple.com/documentation/activitykit/displaying-live-data-with-live-activities

示例代码:

struct LockScreenLiveActivityView: View {
    let context: ActivityViewContext<PizzaDeliveryAttributes>
    
    var body: some View {
        VStack {
            Spacer()
            Text("\(context.state.driverName) is on their way with your pizza!")
            Spacer()
            HStack {
                Spacer()
                Label {
                    Text("\(context.attributes.numberOfPizzas) Pizzas")
                } icon: {
                    Image(systemName: "bag")
                        .foregroundColor(.indigo)
                }
                .font(.title2)
                Spacer()
                Label {
                    Text(timerInterval: context.state.deliveryTimer, countsDown: true)
                        .multilineTextAlignment(.center)
                        .frame(width: 50)
                        .monospacedDigit()
                } icon: {
                    Image(systemName: "timer")
                        .foregroundColor(.indigo)
                }
                .font(.title2)
                Spacer()
            }
            Spacer()
        }
        .activitySystemActionForegroundColor(.indigo)
        .activityBackgroundTint(.cyan)
    }
}
Run Code Online (Sandbox Code Playgroud)

实际上,代码非常简单。我们可以使用timerInterval来制作倒计时动画。但是当计时器结束时,我想更新实时活动视图。如果用户重新打开应用程序,我可以更新它,但是如果用户不打开应用程序会发生什么?有没有办法在不使用推送通知的情况下更新实时活动?

ios swift swiftui

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