小编che*_*sam的帖子

Xcode 8自定义字体未显示在界面构建器中

我想在我的iOS应用程序中使用自定义字体(Bebas Neue).我采取的步骤是:

  1. 将.otf文件复制到项目中.
  2. 确认.otf文件已将项目设置为目标.
  3. 在plist中的"应用程序提供的字体"中添加了.otf文件.
  4. 在Build Phases中,.otf文件位于"Copy Bundle Resources"中.
  5. 在我的Mac上安装字体.
  6. 尝试打印出所有可用的字体,但我看不到自定义字体.

我用过的代码:

for name in UIFont.familyNames() {
  println(name)
  if let nameString = name as? String
  {
    println(UIFont.fontNamesForFamilyName(nameString))
  }
}
Run Code Online (Sandbox Code Playgroud)
  1. 试图在代码中设置字体,它工作.

我用过的代码:

textLabel?.font = UIFont(name: "BebasNeueRegular", size: 14)
Run Code Online (Sandbox Code Playgroud)
  1. 但是我不能在界面构建器中设置它.任何的想法?

截图:

字形 字体名录

xcode custom-font ios swift

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

iOS 9和iOS 10中的App Transport Security问题

Apple宣布NSAllowArbitraryLoads不会很快工作.因此,在iOS 10中,我在info.plist中有这个:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>myAPIdomain</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
    </dict>
Run Code Online (Sandbox Code Playgroud)

这适用于我在UIWebView中的API请求和内容.但是,在iOS9中,NSAllowsArbitraryLoadsInWebContent不受支持,建议包括NSAllowsArbitraryLoadsiOS 9支持.但我认为这会覆盖我的NSExceptionDomains设置?如何在iOS 9和iOS 10上为我的API和UIWebView提供HTTP请求仍然可以遵循Apple的规则?

编辑

支持iOS 9和iOS 10:

<key>NSAppTransportSecurity</key>
        <dict>
            <key>NSExceptionDomains</key>
            <dict>
                <key>myAPIdomain</key>
                <dict>
                    <key>NSIncludesSubdomains</key>
                    <true/>
                    <key>NSExceptionAllowsInsecureHTTPLoads</key>
                    <true/>
                </dict>
            </dict>
            <key>NSAllowsArbitraryLoadsInWebContent</key>
            <true/>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
Run Code Online (Sandbox Code Playgroud)

ios

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

Android Firebase 无法刷新电子邮件验证状态

在我的 Android 应用程序中,我正在创建用户并发送验证电子邮件。当用户通过单击收到的电子邮件中的链接进行验证后,我想进入下一页。但是,验证状态没有更新,所以我无法继续。我试过注销并再次登录,这有效,但我不想以这种方式刷新状态。有任何想法吗?

这是我的代码:

public void onClickContinueBtn() {
   final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
   user.reload().addOnCompleteListener(new OnCompleteListener<Void>() {
       @Override
       public void onComplete(@NonNull Task<Void> task) {
           if(task.isSuccessful()) {
               if(!user.isEmailVerified()){
                   // not verified block
                   // get into here even if verified
               } else {
                   // email verified, go to next page
               }
           } else {
               // do nothing, or show error
           }
       }
   });
}
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-authentication

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

Android MediaMuxer java.lang.IllegalStateException:无法停止复用器

我正在使用这个库来录制来自 USB 摄像头的视频。我使用的代码如下:

try {
    private MediaMuxerWrapper mMuxer;
    mMuxer = new MediaMuxerWrapper("FolderName", ".mp4");
    new MediaVideoEncoder(mMuxer, mMediaEncoderListener);
    mMuxer.prepare();
    mMuxer.startRecording();
} catch (final IOException e) {

}

private final MediaEncoder.MediaEncoderListener mMediaEncoderListener = new MediaEncoder.MediaEncoderListener() {
        @Override
        public void onPrepared(final MediaEncoder encoder) {
            if (encoder instanceof MediaVideoEncoder)
                try {
                    mWeakCameraView.get().setVideoEncoder(encoder);
                } catch (final Exception e) {
                    Log.e(TAG, "onPrepared:", e);
                }
            if (encoder instanceof MediaSurfaceEncoder)
                try {
                    mWeakCameraView.get().setVideoEncoder(encoder);
 mUVCCamera.startCapture(((MediaSurfaceEncoder)encoder).getInputSurface());
                } catch (final Exception e) {
                    Log.e(TAG, "onPrepared:", e);
                }
        }

        @Override
        public …
Run Code Online (Sandbox Code Playgroud)

java mp4 android muxer android-mediacodec

5
推荐指数
0
解决办法
3035
查看次数