Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
639 views
in Technique[技术] by (71.8m points)

objective c - UITableViewCell content overlaps delete button when in editing mode in iOS7

I am creating a UITableView with custom UITableViewCells. iOS 7's new delete button is causing some problems with the layout of my cell.

If I use the "Edit" button, which makes the red circles appear I get the problem, but if I swipe a single cell it looks perfect.

This is when the Edit button is used:

[self.tableView setEditing:!self.tableView.editing animated:YES];

Content overlaps the delete button

This is when I swipe a single cell:

Content is placed right

As you can se my labels overlaps the delete button in the first example. Why does it do this and how can I fix it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

try using the accessoryView and editingAccessoryView properties of your UITableViewCell, instead of adding the view yourself.

If you want the same indicator displayed in both editing and none-editing mode, try setting both view properties to point at the same view in your uiTableViewCell like:

self.accessoryView = self.imgPushEnabled;
self.editingAccessoryView = self.imgPushEnabled;

There seems to be a glitch in the table editing animation in IOS7, giving an overlap of the delete button and the accessoryView when switching back to non-editing state. This seems to happen when the accesoryView is specified and the editingAccessoryView is nil.

A workaround for this glitch, seems to be specifying an invisible editingAccessoryView like:

self.editingAccessoryView =[[UIView alloc] init];
self.editingAccessoryView.backgroundColor = [UIColor clearColor];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...