2012-06-21 2 views
0

내 UITableView의 크기를 변경하려고합니다. 내보기의 맨 아래에 광고가 있고 스크롤하면 광고도 함께 스크롤됩니다. UITableView가 스크롤되는지 여부에 관계없이 광고가 항상 뷰의 아래쪽에 유지되도록 UITableView의 크기를 어떻게 변경할 수 있는지 궁금합니다. TableView의 프레임 크기를 변경하려고 시도했지만 작동하지 않습니다.AdWhirl Ad에 맞게 UIViewTable의 크기를 변경하십시오.

- (void)viewDidAppear:(BOOL)animated 
{ 
tableView.frame = CGRectMake()... 
} 

또한 scrollViewDidScroll : 선택기에서 변경해 보았지만 행운은 없습니다. 어쨌든 높이를 변경할 수있어 바닥에 광고와 충돌하지 않습니까? 감사!

+0

는 IB가 jQuery과를 만들기 위해 사용하십니까? –

답변

0

. 원하는 결과가 원하는 형제보기 (두 개의보기가 공통 superview에 추가됨)가 필요하지만 self.tableView에 대한 "superview"가 없기 때문에 문제가 될 수 있습니다.

UITableView 및 광고보기가 두 개의 하위보기 인 새 UIViewController 하위 클래스를 만들어야합니다. 컨트롤러가 나타날 때 테이블 뷰 셀 선택을 취소 할뿐만 아니라 테이블 뷰에 대한 데이터 소스 설정 및 위임 같은 작업을 처리해야합니다. 이것은 조금 더 많은 일이며 약간의 치료가 필요하지만 확실히 할 수 있습니다.

나는 함께 발생했습니다 아래에서 간단한 예를 들어 당신이 시작됩니다

// Header 
@interface CustomTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> 
- (id)initWithStyle:(UITableViewStyle)tableViewStyle; 

@property (nonatomic, readwrite, retain) UITableView* tableView; 
@end 

// Source 
@interface CustomTableViewController() 
@property (nonatomic, readwrite, assign) UITableViewStyle tableViewStyle; 
@end 

@implementation CustomTableViewController 

@synthesize tableView; 
@synthesize tableViewStyle = _tableViewStyle; 

- (id)initWithStyle:(UITableViewStyle)tableViewStyle { 
    if ((self = [super initWithNibName:nil bundle:nil])) { 
    _tableViewStyle = tableViewStyle; 
    } 
    return self; 
} 

- (void)loadView { 
    [super loadView]; 

    self.tableView = [[UITableView alloc] initWithStyle:self.tableViewStyle]; 
    self.tableView.autoresizingMask = (UIViewAutoresizingMaskFlexibleWidth 
            | UIViewAutoresizingMaskFlexibleHeight); 
    self.tableView.delegate = self; 
    self.tableView.dataSource = self; 
    [self.view addSubview:self.tableView]; 

    // Create your ad view. 
    ... 

    adView.autoresizingMask = (UIViewAutoresizingMaskFlexibleWidth 
          | UIViewAutoresizingMaskFlexibleTopMargin); 
    [self.view addSubview:adView]; 

    [adView sizeToFit]; 
    self.tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - adView.frame.size.height); 
    adView.frame = CGRectMake(0, self.view.bounds.size.height - adView.frame.size.height, self.view.bounds.size.width, adView.frame.size.height); 

    [self.tableView reloadData]; 
} 

- (void)viewDidUnload { 
    self.tableView = nil; 

    [super viewDidUnload]; 
} 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    NSIndexPath* selectedIndexPath = [self.tableView indexPathForSelectedRow]; 
    if (nil != selectedIndexPath) { 
    [self.tableView deselectRowAtIndexPath:selectedIndexPath animated:animated]; 
    } 
} 

@end 
+0

나는 이걸 시도해 보았고, 내보기가 검은 색이었고 화면에 아무것도 나타나지 않았다. – kamran619

+0

사용자 정의 테이블 뷰 컨트롤러를 구현해야 할 가능성이 높습니다. – featherless

+0

나는 Objective-C에 꽤 익숙하며 내일까지 클라이언트를 위해 앱을 푸시해야한다. 이 작업을 수행하는 쉬운 빠른 방법이 있습니까? – kamran619

0

이 문제를 해결하는 간단한 방법은 UITableView에 .XIB 파일을 사용하는 것입니다. 그런 다음 Interface Builder를 사용하여 매우 쉽게 높이를 변경합니다.

이 게시물을 통해 이동하시기 바랍니다 다음 IB 파일을 해달라고하는 경우 : UITableViewControllers self.view == self.tableViewHow do I resize the UITableView's height dynamically?

+0

나는 그것을 동적으로 편집 해 보았고 작동하지 않았다. 인터페이스 빌더를 사용하여 조정했지만 행운은 없다. – kamran619

관련 문제