2013-09-23 8 views
0

사파리 iPad가 탭을 ​​추가하고 새 탭이 추가 될 때 모든 탭의 크기가 변경되는 것과 같이 런타임에 버튼을 추가 할 때 기존 UIButton의 크기를 조정하려고합니다. 그리고 나는 그것을 aotolayout이나 autoresizingmask를 사용해서하고 싶다.런타임에 자동 크기 조정 UIButton.

감사합니다.

답변

1

단추에 대한 참조를 유지하기 위해 변경 가능한 모음을 만듭니다. NSMutableArray를 만들려면 NSMutableArray를 만들고 NSMutableArray를 만들려면 NSMutableArray를 만듭니다. 헤더 파일에서 클래스 구현에 다음 NSMutableSet buttonsSet 같은 바르를 선언 :

float x=0,y=0; 
buttonsSet = [[NSMutableSet alloc] init]; 
for(NSMutableDictionary *dict in places) { 
    NSLog(@"x: %f",x); 
    x=x+25; 
    y=y+25;// Vary these depending on where you want the buttons to be 
    UIButton *button = [[[UIButton alloc] initWithFrame:CGRectMake(x,y,25,25)] autorelease]; 
    button.backgroundColor=[UIColor redColor]; 
    [buttonsSet addObject:button]; 
    [self addSubview:button]; 
} 

이 당신이 찾고있는 무엇을해야한다.

+0

답변 주셔서 감사합니다 abhishek,하지만 나는 autolayout 또는 autoresizing 마스크를 통해 그것을 할 수있는 방법을 찾고 있는데요. 어쨌든 당신의 대답에 +1. – Nilesh