当前位置: 编程技术>移动开发
本页文章导读:
▪(3)UITabBar and UINavigationController基础教程之UITableView的插入删除移动 (三)UITabBar and UINavigationController基础教程之UITableView的插入删除移动之前我们实现了页面切换以及UITextField键盘隐藏及防止键盘遮挡
(一)UITabBar and UINavigationController基础教程之切换页面ht.........
▪ 除开xcode编译warning:ld: warning: directory not found for option ' 去掉xcode编译warning:ld: warning: directory not found for option '首先确定你是真的不用了.
选择工程, 编译的 (targets)
选择 Build Settings 菜单
查找 Library Search Paths 和 Framework Search Paths, 删掉编译报wa.........
▪ unity3d: Asset Store 下载的package寄放位置 unity3d: Asset Store 下载的package存放位置Windows 8,C:\Users\<username>\AppData\Roaming\Unity\Asset Store
Mac OS X,~/Library/Unity/Asset Store ......
[1](3)UITabBar and UINavigationController基础教程之UITableView的插入删除移动
来源: 互联网 发布时间: 2014-02-18
(三)UITabBar and UINavigationController基础教程之UITableView的插入删除移动
接下来我们在.h文件中实现
之前我们实现了页面切换以及UITextField键盘隐藏及防止键盘遮挡
(一)UITabBar and UINavigationController基础教程之切换页面http://blog.csdn.net/zhangyankan/article/details/12833619
(二)UITabBar and UINavigationController基础教程之UITextField键盘隐藏及防止键盘遮挡http://blog.csdn.net/zhangyankan/article/details/12842205
今天我们来实现一下简单的UITableView的插入删除移动
首先我们在.m文件中
#import <UIKit/UIKit.h> #import "JBaseViewController.h" @interface JThirdViewController : UITableViewController<UITableViewDataSource,UITableViewDataSource> @property (strong, nonatomic) NSMutableArray *list; @end
接下来我们在.h文件中实现
#import "JThirdViewController.h" @interface JThirdViewController () @end @implementation JThirdViewController @synthesize list; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization [[self navigationItem]setRightBarButtonItem:[self editButtonItem]]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:@"美国", @"菲律宾",@"黄岩岛", @"中国", @"泰国", @"越南", @"老挝",@"日本" , nil]; self.list = array; self.navigationItem.title = @"列表"; self.tableView.editing = YES; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tableView reloadData]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return list.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell==nil) { cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]autorelease]; // cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease]; // cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease]; // cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier]autorelease]; } // Configure the cell... NSUInteger row = [indexPath row]; cell.textLabel.text=[self.list objectAtIndex:row]; UIImage *image = [UIImage imageNamed:@"add_file.png"]; cell.imageView.image = image; UIImage *highLighedImage = [UIImage imageNamed:@"add_list.png"]; cell.imageView.highlightedImage = highLighedImage; cell.detailTextLabel.text =@"haha"; return cell; } #pragma mark - Table view delegate //选中效果 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // NSString *rowString = [self.list objectAtIndex:[indexPath row]]; // UIAlertView * alter = [[UIAlertView alloc] initWithTitle:@"选中的行信息" message:rowString delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; // [alter show]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if(cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType = UITableViewCellAccessoryCheckmark; // cell.accessoryType = UITableViewCellAccessoryDetailButton; // cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; // cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } else { cell.accessoryType = UITableViewCellAccessoryNone; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } //删除 插入 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; if (editingStyle == UITableViewCellEditingStyleDelete) { [self.list removeObjectAtIndex:row]; [tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationAutomatic //UITableViewRowAnimationBottom //UITableViewRowAnimationFade //UITableViewRowAnimationLeft //UITableViewRowAnimationMiddle //UITableViewRowAnimationNone //UITableViewRowAnimationRight //UITableViewRowAnimationTop ]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { NSArray *insertIndexPaths = [NSArray arrayWithObjects:indexPath, nil]; [self.list insertObject:@"aaaa" atIndex:row]; [tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationMiddle]; } } //移动 - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { // return UITableViewCellEditingStyleNone; return UITableViewCellEditingStyleInsert; } -(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } -(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { NSUInteger fromRow = [sourceIndexPath row]; NSUInteger toRow = [destinationIndexPath row]; id object = [self.list objectAtIndex:fromRow]; [self.list removeObjectAtIndex:fromRow]; [self.list insertObject:object atIndex:toRow]; } @end
具体的介绍可以参考我之前发过的
iOS学习之TableView的简单使用http://blog.csdn.net/zhangyankan/article/details/12776961
iOS学习之分段Table View的使用(Grouped样式表格)http://blog.csdn.net/zhangyankan/article/details/12776965
iOS学习之UITableView中Cell的操作http://blog.csdn.net/zhangyankan/article/details/12776975
[2] 除开xcode编译warning:ld: warning: directory not found for option '
来源: 互联网 发布时间: 2014-02-18
去掉xcode编译warning:ld: warning: directory not found for option '
选择工程, 编译的 (targets)
选择 Build Settings 菜单
查找 Library Search Paths 和 Framework Search Paths, 删掉编译报warning的路径即可
首先确定你是真的不用了.
[3] unity3d: Asset Store 下载的package寄放位置
来源: 互联网 发布时间: 2014-02-18
unity3d: Asset Store 下载的package存放位置
Windows 8,C:\Users\<username>\AppData\Roaming\Unity\Asset Store
Windows 8,C:\Users\<username>\AppData\Roaming\Unity\Asset Store
Mac OS X,~/Library/Unity/Asset Store
最新技术文章: