. 원하는 결과가 원하는 형제보기 (두 개의보기가 공통 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
는 IB가 jQuery과를 만들기 위해 사용하십니까? –