0

テーブルのカスタム セクション ヘッダーがあります。ボタンを追加しました
button1.frame = CGRectMake(frame.size.width-70, 5.0, 35.0, 35.0); これにより、ボタンが右上隅に配置されます。ただし、横向きに自動回転すると、ボタンは縦向きモードのときと同じ場所に留まりますか? 私は何が欠けていますか?

-(id)initWithFrame:(CGRect)frame title:(NSString*)title section:(NSInteger)sectionNumber delegate:(id <SectionHeaderViewDelegate>)delegate AllAnswered:(SectionAnswered)sectionAnswered{

self = [super initWithFrame:frame];

if (self != nil) {

    // Set up the tap gesture recognizer.
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleOpen:)];

    tapGesture.cancelsTouchesInView = NO;

    [self addGestureRecognizer:tapGesture];

    _delegate = delegate;
    self.userInteractionEnabled = YES;


    //create applyAll image
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(frame.size.width-70, 5.0, 35.0, 35.0);
    button1.backgroundColor = [UIColor clearColor];
    button1.opaque = NO;
    button1.tag= 1;
    [button1 setImage:[UIImage imageNamed:@"carat-open.png"] forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(applyToAll:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button1];
    _applyButton = button1;

     .............
     }
4

1 に答える 1

0

ボタンの設定ができますautoresizingMask

button1.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
于 2012-12-01T06:46:26.740 に答える