iOS - View 이동 전환 하기 총정리

by digipine posted Nov 01, 2017
?

Shortcut

PrevPrev Article

NextNext Article

ESCClose

Larger Font Smaller Font Up Down Go comment Print
뷰의 추가 또는 삽입  
[self.view insertSubview:viewController.view atIndex:0];
 
[self.view addSubview:viewController.view]; 
 
[self presentModalViewController:viewController animated:YES];  --> 앤 모달뷰
 
[self.navigationController pushViewController:addView animated:YES]; 
 
뷰의 순서 바꾸기
[self.view bringSubviewToFront:self.tempViewController.view]; 
-> tempViewController.view를 가장 앞으로 이동한다. 
 
[self.view sendSubviewToFront:self.tempViewController.view]; 
-> tempViewController.view를 가장 뒤로 이동한다. 
 
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:2]; 
-> 0번 뷰와 2번뷰의 위치를 바꾼다 
   위에서 insertSubView .... atIndex로 뷰의 번호를 지정하면 view가 쌓인다 
   이 순서를 변경할수 있다. 
   주위 해야 할것은 Atindex:number로 뷰를 넣을 경우 해당 뷰가 number로 계속
   지정 되는 것이 아니라 이동후에는 각각의 위치 번호로 된다. 
예) 
[self.view insertSubview:oneController.view atIndex:0];
[self.view insertSubview:twoController.view atIndex:2];
[self.view insertSubview:threeController.view atIndex:2];
--> 이때는 onController.view가      0     
          twoController.view가     1  
          threeController.view가   2   이다. 
여기서 
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:2];  하면
onController.view가      2     
twoController.view가     1  
threeController.view가   0  이 된다. 즉 할당된 번호가 계속 따라 다니는 것이 아니라 
최최 지정 할때만 적용 되며 변경 후에는 뷰스택(?)에 샇인 번호로 바뀐다. 
이거 몰라서 3일 버렸다 왜 원하는 대로 안나올까 하고.... 바보 같이.. 
--> 아직까지는 그렇게 알고 있다. 나두 아이폰 관련 개발 공부 한지 인자 몇일 안되서 
    틀린 정보 일수도 있다. 
 
뷰 스택 로그 찍기 
NSLog([[self.view subviews] description]); 
-> 뷰가 쌓여 있는 스택(?) 순서를 콘솔로 볼수 있다.  
   로그를 볼때는 view에 tag로 번호를 지정한다음에 보면 콘솔에 해당 tag가 나와서 
   한결 보기 편하다. 
 
뷰 addSubview:뷰
 
뷰 inserSubview뷰 atIndex:번호
 
컨트롤러 pushViewController:컨트롤러 애니옵션
 
컨트롤러 presentModalViewController:컨트롤러 애니옵션
TAG •

Articles

1 2 3