在iPhone应用开发中个,常常碰到当用户点击按钮时,需要增加一个表格视图的操作。在开发实现上可以使用在UIViewController中增加一个UITableView视图的方案。
首先从UIViewController派生一个子类类(不需要使用nib文件),在子类loadView方法中装载UITableView,并且程序控制UITableView的大小和位置。代码如下:
// 使用程序创建视图层次关系
- (void)loadView
{
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
contentView.autoresizesSubviews = YES;
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
contentView.backgroundColor = [UIColor clearColor];
[self setView:contentView];
[contentView release];
tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 440) style:UITableViewStylePlain];
[tableView setAutoresizesSubviews:YES];
[tableView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[tableView setDataSource:self];
[tableView setDelegate:self];
[[self view] addSubview:tableView];
}
头文件部分代码
@interface SelectPeopleViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *tableView;
}
@property (nonatomic, retain) UITableView *tableView;
- 浏览: 11438939 次
最新评论
-
wahahachuang8:
我觉得这种东西自己开发太麻烦了,就别自己捣鼓了,找个第三方,方 ...
WebSocket和node.js -
xhpscdx:
写的这么详细,全面,对架构师的工作职责,个人能力都进行了梳理。 ...
架构师之路---王泽宾谈架构师的职责 -
xgbzsc:
是http://www.haoservice.com 吗?
android WIFI定位 -
lehehe:
http://www.haoservice.com/docs/ ...
android WIFI定位 -
lehehe:
http://www.haoservice.com/docs/ ...
android WIFI定位
相关推荐
012 Word Color - 带有 UITableView 和 UICollectionView 的精益 UIViewController 描述:演示如何从 UIViewController 中分离 UITableViewDataSource 和 UICollectionViewDataSource。 参考:
简单的Objective-C和实现,用于摆脱UIViewController和UICollectionView委托以及UIViewController中的数据源代码,并在UIViewControllers之间共享它们。 兼容性 iOS 7.0或更高版本 一体化 通过cocoapods安装(只需...
UITableView的使用,UITableView所在的UIViewController声明两个delegate:UITableViewDelegate和UITableViewDataSource。
在UIViewController内的UITableView中添加静态单元格。什么? 如果UITableView不在UITableViewController内,则不允许将UITableView的单元格设置为静态单元格,因此,不允许在UIViewController内使用Static-Cells ...
在日常开发中经常会用到UIViewController和UITableView,一般都把UITableView代理的代码写在控制器中,但是控制器中代码量一般都不会少,这样无疑会增加控制器的代码量。 在Demo中就通过“代理对象”的方式,将控制...
使用场景:UIViewController 上添加添加UITableView,UITableView的cell 时限向左 向右滑动出现多个操作按钮,可以根据具体使用场景修改代码
2、创建的UITableView继承UIPullToRefreshTableView,同时支持XIB和动态创建两种方式 @interface UIPullToRefreshTableView : UITableView 3、 创建的UIViewController继承UIPullToRefreshViewController @...
UIView/UIViewController UITextView UITableView/UITableViewController UICollectionView UIScrollView UIResponder UIWebView AutoLayout Masonry Quartz 2D Core Animation Audio/Video 编码规范/最佳实践 ...
讲述了UIViewController和UITableViewController,有利于初学者
为了保持这种解耦,没有“UITableView”子类,允许开发者将此行为添加为自己的“UITableView”子类的聚合,而无需创建中间类或直接在管理表委托和数据源的UIViewController中添加. 安装说明 将整个...
为了维持这种解耦,没有UITableView子类,允许开发人员将此行为添加为UITableView自身子类的集合,而无需创建中间类或直接在管理表委托和数据源的UIViewController中添加。 安装说明: 将整个...
UITableView几乎是iOS开发中用处最广的一个控件,当然也是要记相当多东西的一个控件。 创建 首先创建一个新的项目,并添加一个MainViewController的Class文件 打开MainViewController.h文件 @interface ...
1、UIScrollView 嵌套 UITableView 2、UITableView 嵌套 UITableView 3、UITableView 嵌套 子视图控制器 UIViewController
- ( void )hyp_addViewController:(UIViewController *)controller;- ( void )hyp_addViewController:(UIViewController *)controller inFrame:( CGRect )frame;- ( void )hyp_removeViewController:...
已弃用:不再维护此库。 它已被更新的取代。 稳定视图控制器 STableViewController 是一个自定义的 table view controller,支持pull-to-refresh和load-more 。 它旨在具有可以轻松自定义的视图和行为。...
这也将帮助我停止在单个UIViewController子类中实现表的数据源和委托。 ##屏幕截图 ##用法子类DZLoadMoreDataSource类实现-(NSArray *)items方法。 您应该在此方法上返回UITableView的模型项数组。 添加...
Ios简单的备忘录app,刚入门ios开发在网上看到了一个UITableView的使用例子便把网上的... 使用UINavigationController 实现的视图(UIViewController)间切换和数据传递 ; UIAlertView的使用 ; 使用NSData实现数据存储.
在 UITableView 和 MapView 之间创建视差效果,就像 FourSquare 中的视图一样。 SLAppDelegate提供了示例用法。 要求 SLParallaxController使用 ARC 并且需要 iOS 7.0+。 适用于 iPhone 和 iPad。 需要框架MapKit ...
@interface ViewController : UIViewController .... @property ( weak , nonatomic ) IBOutlet UITableView *myTable; @property ( strong , nonatomic ) RTDataSourceAdapter *adapter; .... @end 创建...
一个插入式 UIViewController 子类,具有不断增长的文本输入视图和其他有用的消息传递功能。 旨在替代 UITableViewController 和 UICollectionViewController。 这个库用于我们的 iOS 应用程序。 在成立之初,该库...