내 애플리케이션에 스플릿 뷰가 있으며 가로 모드에서만 활성화됩니다. masterview에서 내가 tableview 있고 마지막 섹션에서 사용자 지정 단추가 있습니다. 문제는 장치 방향을 사용하는 대신 단추 너비가 potrait로 유지된다는 것입니다. 단추 및 뷰에서 setAutoresizingMask를 사용하여 재생하려고했지만 그 중 하나가 작동하지 않습니다.iPad, viewForHeaderInSection의 맞춤 크기 조정 버튼
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger) sectionNum {
if (sectionNum == 4) {
CGRect frameSize;
if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
frameSize = CGRectMake(45.0, 0.0, 600.0, 44.0);
} else {
frameSize = CGRectMake(45.0, 0.0, 680.0, 44.0);
}
UIView *btnView = [[[UIView alloc] initWithFrame:frameSize] autorelease];
// button
UIButton* btnFind = [UIButton buttonWithType:UIButtonTypeCustom];
[btnFind setBackgroundImage:[[UIImage imageNamed:@"buttonblue.png"] stretchableImageWithLeftCapWidth:14.0 topCapHeight:0.0] forState:UIControlStateNormal];
[btnFind setBackgroundImage:[[UIImage imageNamed:@"buttonred.png"] stretchableImageWithLeftCapWidth:14.0 topCapHeight:0.0] forState:UIControlStateHighlighted];
btnFind.frame = frameSize;
btnFind.tag = 1;
[btnFind setTitle:@"Find" forState:UIControlStateNormal];
[btnFind addTarget:self action:@selector(doSearchDoc:) forControlEvents:UIControlEventTouchUpInside];
//[btnFind setAutoresizingMask:UIViewAutoresizingFlexibleRightMargin];
//[btnView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[btnView addSubview:btnFind];
return btnView;
}
return nil;
}
이 문제를 해결할 방법을 알려주세요.
감사합니다.
감사합니다. 이것은 멋지게 작동합니다. – Inoel
제 경우이 더 잘 작동합니다. 코드를 수정하고 .reloadSections를 .reloadData로 바꿉니다. [NSIndexSet indexSetWithIndex : btnSectionIndex] withRowAnimation : NO]; – Inoel