// TestAdListViewController.h
#import <UIKit/UIKit.h>
@interface TestAdListViewController : UIViewController
@end
// TestAdListViewController.m
#import "TestAdListViewController.h"
#import "AdTitleView.h"
#import "tnksdk.h"
#define HEADER_HEIGHT 60
@interface TestAdListViewController ()
@end
@implementation TestAdListViewController {
AdTitleView *titleView;
TnkAdListView *adlistView;
}
- (void) cancelPressed {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
titleView = (AdTitleView *)[[[NSBundle mainBundle] loadNibNamed:@"AdTitleView" owner:self options:nil] objectAtIndex:0];
titleView.frame = CGRectMake(0, 0, self.view.bounds.size.width, HEADER_HEIGHT);
titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[titleView.closeButton addTarget:self action:@selector(cancelPressed) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:titleView];
CGRect rect = CGRectMake(0, HEADER_HEIGHT, self.view.bounds.size.width, self.view.bounds.size.height - HEADER_HEIGHT);
adlistView = [[TnkAdListView alloc] initWithFrame:rect viewController:self];
adlistView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:adlistView];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[adlistView loadAdList];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if (!self.isViewLoaded || !self.view.window) {
// 현재 화면에 떠있지 않으면 무시한다.
return;
}
[adlistView updateAdList];
}
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
if (!self.isViewLoaded || !self.view.window) {
// 현재 화면에 떠있지 않으면 무시한다.
return;
}
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
// do whatever
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
[adlistView updateAdList];
}];
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
@end