ove*_*asy 7 uitableview uinavigationcontroller iad ios5
我正在为博客网站构建应用程序.
我有一个带有UITableViewController的UINavigationController作为它的根视图.
我把它放在故事板中没问题,但是我试图将iAd视图拖到屏幕的底部,xcode不会让我添加它.
看起来我必须从UITableViewController的子类切换到UIViewController的子类,并将我的委托和数据源方法放在我的子类UIViewController中.
这对我来说似乎不对.我只想尝试UITableView的文章标题,顶部是导航栏,底部是iAd ...
建议吗?建议?
提前致谢.
NJo*_*nes 23
其中一个做到这一点的最简单方法是使用UITableView的tableFooterView属性.是的,我知道页脚停留在桌子的底部,但它没有必要.您可以在表格中设置其框架.像这样添加iAd作为页脚:
self.tableView.tableFooterView = iAd;
Run Code Online (Sandbox Code Playgroud)
然后,要在表格滚动时调整iAd的框架,请实现UIScrollView委托方法:(这是可能的,因为UITableView它是子类UIScrollView)
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGRect iAdFrame = iAd.frame;
CGFloat newOriginY = table.contentOffset.y + table.frame.size.height - iAdFrame.size.height;
CGRect newIAdFrame = CGRectMake(iAdFrame.origin.x, newOriginY, iAdFrame.size.width, iAdFrame.size.height);
iAd.frame = newIAdFrame;
}
Run Code Online (Sandbox Code Playgroud)
您可以看到实现很简单.我们只是使用它contentOffset y来确定iAd帧的下行距离.
| 归档时间: |
|
| 查看次数: |
5723 次 |
| 最近记录: |