方向更改后更新视图

时间:2017-10-21 19:43:01

标签: ios swift xcode swift4

我在滚动视图(从集合视图)的顶部创建了一个模糊视图,当用户转到设置时,该视图显示在所有屏幕上,但当此模糊视图处于活动状态时方向更改时,它不会覆盖所有的屏幕。我实现了相同的功能,以便在捕获方向更改时更新帧大小和原点,但它仍然无法正常工作。

import javax.crypto.spec.*;
import java.security.*;
import javax.crypto.*;

public class Main
{
   private static String algorithm = "RC6";

   public static void main(String []args) throws Exception {
      String toEncrypt = "The shorter you live, the longer you're dead!";

      System.out.println("Encrypting...");
      byte[] encrypted = encrypt(toEncrypt, "password");

      System.out.println("Decrypting...");
      String decrypted = decrypt(encrypted, "password");

      System.out.println("Decrypted text: " + decrypted);
   }

   public static byte[] encrypt(String toEncrypt, String key) throws Exception {
      // create a binary key from the argument key (seed)
      SecureRandom sr = new SecureRandom(key.getBytes());
      KeyGenerator kg = KeyGenerator.getInstance(algorithm);
      kg.init(sr);
      SecretKey sk = kg.generateKey();

      // create an instance of cipher
      Cipher cipher = Cipher.getInstance(algorithm);

      // initialize the cipher with the key
      cipher.init(Cipher.ENCRYPT_MODE, sk);

      // enctypt!
      byte[] encrypted = cipher.doFinal(toEncrypt.getBytes());

      return encrypted;
   }

   public static String decrypt(byte[] toDecrypt, String key) throws Exception {
      // create a binary key from the argument key (seed)
      SecureRandom sr = new SecureRandom(key.getBytes());
      KeyGenerator kg = KeyGenerator.getInstance(algorithm);
      kg.init(sr);
      SecretKey sk = kg.generateKey();

      // do the decryption with that key
      Cipher cipher = Cipher.getInstance(algorithm);
      cipher.init(Cipher.DECRYPT_MODE, sk);
      byte[] decrypted = cipher.doFinal(toDecrypt);

      return new String(decrypted);
   }
}

我尝试从超级视图中删除视图,并在更改方向后再次添加视图但仍无法正常工作。

有人可以告诉我为什么它不会更新模糊视图框架以及如何修复它?

0 个答案:

没有答案