將tableview的邊框 四角改成圓角的數組
Radius 表明弧度半徑 函數
table.layer.cornerRadius = 10;spa
table.layer.borderWidth = 1;//邊框的透明度?,是的我確實用它改了透明度!3d
be Continued。。。指針
// 添加 tableviewCell 右側的小箭頭圖標orm
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];索引
//設置tableview cell的邊框 顏色。rem
tableview.separatorColor = [UIColor redColor];get
tableViewStyle 爲 Grouped 時tableview 只顯示已有的cell,下面沒有的不補全(即沒有多餘橫線)string
1. 隱藏tableView的滾動條
leftTableView.showsVerticalScrollIndicator = NO;
2.在tablev 的右側添加一個索引的控件!例如通訊錄快捷收索! tableview 必須是分組的 例如 title 爲key 咱們會利用下面的委託
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return key;
}
//建立編輯按鈕
-(void) CreateBarBtn
{
mEdit = [[UIBarButtonItemalloc] initWithTitle:@"編輯"style:UIBarButtonItemStylePlaintarget:selfaction:@selector(pressEdit)];
mFinish= [[UIBarButtonItemalloc] initWithTitle:@"結束"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(pressFinish)] ;
mDeleteBtn = [[UIBarButtonItemalloc] initWithTitle:@"刪除"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(pressDelete)] ;
mIsEdit = NO ;
self.navigationItem.rightBarButtonItem = mEdit ;
mIsDelete = NO ;
}
-(void) pressDelete
{
for (int k = 0 ; k < [mDeleteArray count] ; k++)
{
NSString* strDelete = [mDeleteArray objectAtIndex:k] ;
for (int i = 0 ; i < [mArrayData count] ; i++)
{
NSMutableArray* smallArray = [mArrayData objectAtIndex:i] ;
for (int j = 0 ; j < [smallArray count]; j++) {
NSString* str = [smallArray objectAtIndex:j] ;
if ([strDelete isEqualToString:str])
{
[smallArray removeObject:str] ;
}
}
}
}
[mTableViewreloadData] ;
}
//開啓編輯狀態
-(void) pressEdit
{
self.navigationItem.leftBarButtonItem = mDeleteBtn ;
self.navigationItem.rightBarButtonItem = mFinish ;
[mTableViewsetEditing:YESanimated:YES] ;
mIsEdit = YES ;
mIsDelete = YES ;
}
//結束編輯狀態
-(void) pressFinish
{
self.navigationItem.leftBarButtonItem = nil ;
self.navigationItem.rightBarButtonItem = mEdit ;
[mTableView setEditing:NO animated:YES] ;
mIsEdit = NO ;
mIsDelete = NO ;
}
//設置組標題
-(NSString*) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [NSString stringWithFormat:@"%d組",section];
}
//設置結尾標題
-(NSString*) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return [NSString stringWithFormat:@"%d組結束",section];
}
//設置組頭高度
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 80 ;
}
//設置單元格行高
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60 ;
// if (indexPath.row % 2 == 0) {
// return 80 ;
// }
// else
// {
// return 40 ;
// }
}
//選中某行時函數被調用
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (mIsDelete == YES)
{
NSString* strDelete = [[mArrayData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] ;
[mDeleteArray addObject:strDelete] ;
} else
{
RootVC* rootVC = [[RootVC alloc] init] ;
//rootVC.mArrayData = mArrayData ;
[self.navigationController pushViewController:rootVC animated:YES] ;
}
}
//當編輯操做完成提交時被調用
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"delete!!!") ;
// 得到當前數組指針
NSMutableArray* smallArray = [mArrayData objectAtIndex:indexPath.section] ;
//兩種數據刪除方式
// NSString* str = [smallArray objectAtIndex:indexPath.row] ;
// [smallArray removeObject:str] ;
[smallArray removeObjectAtIndex:indexPath.row] ;
[tableView deleteRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationRight];
//必定要從新加載數據 ?--->爲何呢?
[tableView reloadData] ;
}
//更改刪除按鈕文字
-(NSString*) tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row % 2 == 0) {
return @"刪除";
}
else
{
return @"Delete";
}
}
//取消選擇某行時被調用
-(void) tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (mIsDelete == YES)
{
NSString* str = [[mArrayData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] ;
for (int i = 0 ; i < [mDeleteArray count] ; i++) {
NSString* strDelete = [mDeleteArray objectAtIndex:i];
if ([str isEqualToString:strDelete])
{
[mDeleteArray removeObject:strDelete];
}
}
}
NSLog(@"%d行取消",indexPath.row) ;
}
//即將開始編輯
-(void) tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"will Begin Edit!");
}
//已經結束編輯被調用
-(void) tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"已經結束編輯");
}
//是否能夠進行編輯操做
-(BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
returnYES ;
if (indexPath.row % 2 == 0) {
return YES ;
} else
{
return NO ;
}
}
//決定編輯按鈕風格 滑動刪除按鈕的出現
-(UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
//多組操做風格
returnUITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;
}
//是否能夠移動單元格
-(BOOL) tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
returnYES ;
}
//交換兩個單元格子的位置
-(void) tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
}