UITableViewController
2015-08-19 21:07
549 查看
MyTableViewController.m
#import "MyTableViewController.h" @interface MyTableViewController () @property(nonatomic,retain)NSMutableArray *arr; @property(nonatomic,retain)UIRefreshControl *control; @end @implementation MyTableViewController -(void)dealloc { [_arr release]; [super dealloc]; } -(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.arr = [NSMutableArray arrayWithObjects:@"宋江", @"卢俊义", @"吴用", @"公孙胜", @"关胜", @"林冲", @"秦明" ,@"呼延灼" , @"花容",@"柴进", @"李应", @"朱仝",@"鲁智深",@"武松",nil]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; // 系统默认的刷新 self.control=[[UIRefreshControl alloc]init]; self.control.attributedTitle=[[NSAttributedString alloc]initWithString:@"正在加载数据..."]; [self.view addSubview:self.control]; [self.control addTarget:self action:@selector(changeValue:) forControlEvents:UIControlEventValueChanged]; } -(void)changeValue:(UIRefreshControl *)control { // 先关闭刷新的效果 [control endRefreshing]; [self.arr addObject:@"limuran"]; [self.tableView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - Table view data source - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.arr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *resue=@"resue"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:resue]; if (!cell) { cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:resue]autorelease]; } cell.textLabel.text=self.arr[indexPath.row]; return cell; } #pragma mark 设置是否允许给tableView上的cell添加菜单 -(BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } #pragma mark 这个方法是设置是否允许给tableView上得cell添加事件 -(BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { return YES; } // 最后一步:点击菜单上得按钮之后会触发的方法 -(void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { if(action == @selector(copy :)){ NSLog(@"拷贝"); } }
相关文章推荐
- 利用media query写响应式布局
- The Unique MST 判断生成树是否唯一
- HDU 3698 Let the light guide us
- UDKtoUE4Tool-UDKUE3资源移植UE4工具
- uestc 360(区间合并)
- 图片相关 UIActionSheet
- POJ1986 Distance Queries(LCA最近公共祖先)
- UICollectionView在初始化的时候移动到某个距离
- 参加北京bluemix云计算大会偶记
- uiView 设置圆角
- CUICatalog: Invalid asset name supplied: (null) _configureCellForDisplay:forIndexPath
- UI计算器的设计
- ios 延迟调用 && UIImageView && UILabel && UISegmentedControl && UISwitch && UISlider
- ios UITextField
- Building A Fence, usaco 2008 Oct
- queue队列容器
- UIScrollView
- UI16_数据持久化(NSUserDefaults,简单对象,复杂对象归档反归档,文件管理者"删除添加文件")
- Codeforces Round #241 (Div. 2) AGuess a number!
- IOS学习之路十二(UITableView下拉刷新页面)