小编The*_*ook的帖子

如何在IOS中设置视图的最大宽度?

我的应用程序有一个基本的登录屏幕,一个外盒,里面有一些文本字段和按钮.我将框设置为填满屏幕.但是,在某些设备上,这个盒子会很大.我想为它设置最大宽度和高度.

如何为视图设置最大宽度和高度?

ios autolayout

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

如何在Swift中获得18位数的当前时间戳?

我想得到这样的当前时间戳:

636110767775716756?
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时:

NSDate().timeIntervalSince1970
Run Code Online (Sandbox Code Playgroud)

它返回一个这样的值:

1475491615.71278
Run Code Online (Sandbox Code Playgroud)

如何以我想要的格式访问当前时间戳记?我从这里查看日期:

time timestamp ios swift

18
推荐指数
3
解决办法
4万
查看次数

如何在iOS中使用预设的cookie或标题在Safari中打开URL?

在我的应用程序中,我有一个屏幕,用户可以单击不同类型的文件来查看和下载它们.但是,只有在用户通过网站登录后才能访问此屏幕.

我使用此方法使用我的URL启动Safari浏览器:

UIApplication.sharedApplication().openURL(NSURL(string: url)!)
Run Code Online (Sandbox Code Playgroud)

但是,用户被重定向到登录屏幕,因为他还没有被授权使用该网站.

我的问题是,如何将cookie或标题传递给Safari并使用这些URL启动URL?

objective-c ios swift

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

在Android中授权用户的最安全方式是什么?

在我的应用程序中,用户使用Web服务登录,Web服务返回授权密钥.在此之后,每个请求用户都使用此密钥完成.

我的问题是如何安全地存储这个密钥?我一直把它存储在SharedPreferences中,但这对我来说听起来不太安全.

java security android

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

如何定义一个静态字典并在 Java 中访问它?

如何定义一个静态字典并在 Java 中访问它。我在 iOS Swift 中这样做:

let pairs = [
     "Name1": "Value1", 
     "Name2": "Value2"
]

print(pairs["Name1"]) // Value1
Run Code Online (Sandbox Code Playgroud)

如何在 Java 中做这样的事情?

java android

5
推荐指数
2
解决办法
7287
查看次数

如何在不使用 CAPTCHA 的情况下保护我的应用程序的注册 API 免受垃圾邮件发送者的侵害?

我的应用程序有一个注册服务,用户可以自己注册。然而,有恶意的人可以编写一个脚本,在几秒钟内注册数千个帐户。

我的后端开发人员建议我们在移动应用程序中使用验证码。但是我没有看到任何使用验证码的应用程序,它们的用户体验很差。

我的问题是如何防止此类攻击并保护我们应用程序中的服务?

security mobile captcha

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

如何在BottomSheetDialog中的GridView中向上滚动?

我创建了一个里面BottomSheetDialog有一个GridView。当BottomSheetDialog被打开,你可以滚动下来正常。这样做会使BottomSheetDialog扩展到全屏并GridView正常向下滚动。

但是,当用户尝试向上滚动;而不是向上滚动GridViewBottomSheetDialog缩小并关闭。

我想要的是能够在GridViewBottomSheetDialog改变尺寸的情况下上下滚动。

怎么做?

我的代码:

final BottomSheetDialog dialog = new BottomSheetDialog(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.grid, null);
dialog.setContentView(view);
Run Code Online (Sandbox Code Playgroud)

网格.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <GridView
        android:background="#FFFFFF"
        android:id="@+id/gridview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="3"
        android:stretchMode="columnWidth"
        android:horizontalSpacing="4dp"
        android:verticalSpacing="4dp"
        android:gravity="center"
        />

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

android bottom-sheet

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

如何在应用程序未运行时堆叠Firebase Cloud Messaging通知?

Firebase Cloud Messaging用来从我的服务器发送推送通知到我的Android应用程序.

当应用程序运行时,通知会堆叠,因为我将它们设置为我的组中的组FirebaseMessagingService.这很好.

但是,当应用程序未运行时,通知不会堆叠,并且每个通知都会单独显示.这不好.

即使应用程序未运行,如何确保通知堆叠?

这是我的FirebaseMessagingService样子:

public class MyFcmListenerService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        RemoteMessage.Notification notification = remoteMessage.getNotification();

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)

                .setSmallIcon(R.drawable.notif_white)
                .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.notif_white))
                .setContentTitle(getResources().getString(R.string.app_name))
                .setContentText(notification.getBody())
                .setAutoCancel(true)
                .setPriority(2)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent)
                .setGroup("1")
                .setGroupSummary(true)
                .setOnlyAlertOnce(true);


        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0 , notificationBuilder.build());

        }
    }
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-cloud-messaging

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

如何从Swift中的两个struct数组中删除常用项

在我的应用程序中,我有两个struct数组,我想从其中一个中删除常用项.我的结构:

struct PeopleSelectItem {
    var name = ""
    var id = ""
    var added = false
}
Run Code Online (Sandbox Code Playgroud)

我的阵列:

var people : [PeopleSelectItem] = []
var selectedPeople : [PeopleSelectItem] = []
Run Code Online (Sandbox Code Playgroud)

我想从people数组中删除项目(如果它们存在(通过id比较)在selectedPeople数组上).

我尝试了几个数组过滤和转换设置,但没有一个工作.我能在这做什么?

谢谢!

ios swift

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