2012-10-31 7 views
0

나는 removeFromSuperView 및 addSubview.the 코드를 사용하지 않고 UIView의 내용을 동적으로 변경하고 싶습니다. 원하는 코드입니다.UIView의 내용을 동적으로 변경할 수 있습니까?

int screenWidth = [[UIScreen mainScreen] bounds].size.width; 
int screenHeight = [[UIScreen mainScreen]bounds].size.height; 
UIView *currentView = [[UIView alloc]initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)]; 
UIView *nextView = [[UIView alloc]initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)]; 

[self.view addSubview:currentView]; 

currentView = nextView; 

//when this code run,appearing currentView swap nextView. 
[self.view reload]; 

답변

1

확실히. 멋지게 보이게하려면 원하는 속성으로 "끝"보기를 만들고 고정 transition 메서드를 사용하십시오 : +transitionFromView:toView:duration:options:completion:.

필요에 따라보기를 제거하고 추가하므로 이러한 메소드를 호출 할 필요가 없습니다. 그렇지 않은 경우 janusfidel에 의해 제안 된 -setHidden: 방법을 사용하면보고 싶지 않은보기를 숨길 수 있습니다.

0
//in viewdidload 
{ 
........ 
........ 
[self.view addSubview:currentView]; 
[self.view addSubview:nextView]; 
nextView .hidden = YES; 
} 

-(void)changeView 
{ 
if(!currentView .hidden) 
{ 
currentView .hidden =YES; 
nextView .hidden = NO; 
} 
else 
{ 
currentView .hidden =NO; 
nextView .hidden = YES; 
} 
} 
관련 문제