Do not slide:
?
1 |
tableView.userInteractionEnabled = NO; |
You can also set the Userinteractionenable property in the storyboard
Show Guide Arrows:
?
12 |
// 显示导向箭头 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
Custom buttons:
?
12345678910111213141516171819202122 |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static
NSString *ID = @
"device"
;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
HHDevice *device = self.device[indexPath.row];
// 给cell的控件赋值
cell.textLabel.text = device.nickName;
cell.detailTextLabel.text = device.IMSI;
// 自定义一个button
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(0, 0, 55, 25);
btn.backgroundColor = [UIColor clearColor];
btn.tag = indexPath.row;
// 给按钮绑定tag,好知道点击的是哪行
[btn setTitle:@
"Edit"
forState:UIControlStateNormal];
[btn addTarget:self action:@selector(Edit:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = btn;
return
cell;
}
|
To set a background image:
?
12345678910111213141516 |
1.给tableView设置背景view
UIImageView *backImageView=[[UIImageViewalloc]initWithFrame:self.view.bounds];
[backImageView setImage:[UIImageimageNamed:@
"liaotianbeijing"
]];
self.tableView.backgroundView=backImageView;
2.让cell透明
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = [tableViewdequeueReusableCellWithIdentifier:@
"METext"
forIndexPath:indexPath];
cell.backgroundColor=[UIColor clearColor];
//关键语句
[cell setCellInfo:dic];
//自定义类目方法
return
cell;
}
|
Set the background image for TableView, but if you set the background Backgroundview directly, the background map will not be displayed because the cell on TableView is opaque by default, so the solution is to make the cell transparent.
To set a picture for a cell:
?
1 |
cell.imageView.image = [UIImage imageNamed:@ "childish_folder" ]; |
Cell Swipe Delete function:
?
12345 |
- ( void )tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@ "userId是:%@" ,_userId); NSLog(@ "长按的行号是:%d" ,[indexPath row]); } |
The Nsinteger output of the input format is%ld:
?
1 |
NSString *number = [@ "NO." stringByAppendingString:[NSString stringWithFormat:@ "%ld:" , (indexPath.row + 1)]]; |
If the format is written in%d, Xcode will have a warning.
Some settings for UITableView in iOS