Swift開発メモを行き当たった時記載

https://qiita.com/furusin_oriver/items/b6875f0703dbd49e7737

```android:android
public class MainActivity extends AppCompatActivity {

    static final int REQUEST_CAPTURE_IMAGE = 100;

    Button button1;
    ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViews();
        setListeners();
    }


    protected void findViews(){
        button1 = (Button)findViewById(R.id.button1);
        imageView = (ImageView)findViewById(R.id.imageView);
    }

    protected void setListeners(){
        button1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(
                        MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(
                        intent,
                        REQUEST_CAPTURE_IMAGE);
            }
        });
    }


    @Override
    protected void onActivityResult(
            int requestCode,
            int resultCode,
            Intent data) {
        if(REQUEST_CAPTURE_IMAGE == requestCode
                && resultCode == Activity.RESULT_OK ){
            Bitmap capturedImage =
                    (Bitmap) data.getExtras().get("data");
            imageView.setImageBitmap(capturedImage);
        }
    }
}
```

https://qiita.com/naoi/items/5d6ba9cce141a33e323a

https://qiita.com/suzukihr/items/2f906aa7668155b21072

https://off.tokyo/blog/how-to-access-info-plist/

(00)

```android:android
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    static final int REQUEST_CAPTURE_IMAGE = 100;

    Button button1;
    ImageView imageView1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViews();
        setListeners();
    }


    protected void findViews(){
        button1 = (Button)findViewById(R.id.button1);
        imageView1 = (ImageView)findViewById(R.id.imageView1);
    }

    protected void setListeners(){
        button1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(
                        MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(
                        intent,
                        REQUEST_CAPTURE_IMAGE);
            }
        });
    }


    @Override
    protected void onActivityResult(
            int requestCode,
            int resultCode,
            Intent data) {
        if(REQUEST_CAPTURE_IMAGE == requestCode
                && resultCode == Activity.RESULT_OK ){
            Bitmap capturedImage =
                    (Bitmap) data.getExtras().get("data");
            imageView1.setImageBitmap(capturedImage);
        }
    }
}
```

(0)文字置換
arr0[0] = arr0[0].stringByReplacingOccurrencesOfString("/wp-app", withString: "/")
⑴、swift rename サイト
https://www.youtube.com/watch?v=jRnVjtNLLLk
⑵、swift containerViewを１つのViewControllerに重ねて表示させた時の問題として。
元のViewを親View、重ねて表示するViewを子ViewとしてSwitch,caseを利用して表示・非表示をコントロールするする際、各ViewのbackgroundをDefaultの透過色でなく色指定（白等）する。
<img width="200" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/101462/3e8075c3-4640-14f2-1b80-837ac82811a4.png">
<img width="200" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/101462/204255f7-34be-5fab-62be-3a7bc3ca7e54.png">
<img width="400" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/101462/143445a2-9182-69ea-df46-3c12c901bd0e.png">
(3)、UINavigationBarのTitleをコードで記述する方法
Qiitaの投稿方法下記より習得させてもらいました！！
Qiita Markdown 書き方 まとめ
<a href="https://qiita.com/shizuma/items/8616bbe3ebe8ab0b6ca1"

```swift:swift
    
        let navigationTitle = UILabel(frame:CGRectMake(0, 0, 100, 100))
 
        // fontを設定
        navigationTitle.font = UIFont.systemFontOfSize(21)
 
        // Titleのテキストを設定
        navigationTitle.text = "myTitle"
 
        // textAlignmentを設定
        navigationTitle.textAlignment = .Center
 
        // 設定したTitleを組み込む
        self.navigationItem.titleView = navigationTitle
```

(4)、pickerView
追加UI UIImagePickerControllerDelegate, UINavigationControllerDelegateを追加。
右変数宣言 var cameraSw: Int?にてカメラロールから、カメラ直接からか？選択。
以下ActionButton設定
更に写真のOrientation等を考慮して正方形に切り取る処理は下記で投稿。
https://qiita.com/shinsakujazzbass/items/1c4fed7c5aed910234fc

```swift:swift
   @IBAction func cameraAction(sender: AnyObject) {
        cameraSw=1
        pickImageFromCamera()
    }
    
    @IBAction func galleryAction(sender: AnyObject) {
        cameraSw=0
        accessCameraroll()
        
    }
    @IBAction func photoSend(sender: AnyObject) {
        
        let detaileditViewController = self.storyboard?.instantiateViewControllerWithIdentifier("detailEditView") as!DetailEditViewController
        print("error check wrkImage")
        detaileditViewController.wrkImagex = ImageView.image
        self.presentViewController(detaileditViewController, animated: true, completion: nil)
        
    }
    // カメラロールから写真を選ぶためのメソッド
    func accessCameraroll() {
        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) {
            let controller = UIImagePickerController()
            controller.delegate = self
            controller.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
            self.presentViewController(controller, animated: true, completion: nil)
        }
    }
    
    //カメラで写真を取る
    func pickImageFromCamera() {
        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
            let controller = UIImagePickerController()
            controller.delegate = self
            controller.sourceType = UIImagePickerControllerSourceType.Camera
            self.presentViewController(controller, animated: true, completion: nil)
        }
        
        
    }
    
    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
        
    {
        if(cameraSw==0){
            let pictURL: NSURL = info[UIImagePickerControllerReferenceURL] as! NSURL
            
            picurl = pictURL.absoluteString
            ImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
        }else{
            ImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
            
            //self.dismissViewControllerAnimated(true, completion: nil)
        }
        
        
        self.dismissViewControllerAnimated(true, completion: nil)
        
        
    }
```

(5)パスワード付きURLで特定のURLをアプリのwebViewに表示する。
http://kotaro.jazzman.club/wp-app/loginxz.php?pass=パスワード&ku=0&id=1&appku=2


        print("urlpass"+urlpass!)
        //http://kotaro.jazzman.club/wp-app/loginxz.php?pass=&ku=0&id=1&appku=2
        let requestURL = NSURL(string: urlpass! + "&appku=2" )
        let request = NSURLRequest(URL: requestURL!)
        webView.loadRequest(request)