1
我正在使用表格視圖並使用不同的單元格大小,但是當我刪除單元格時,它顯示在常量位置上,而不是在單元格中間。我應該爲自定義刪除按鈕位置做些什麼?在UITABLE VIEW中更改刪除按鈕的位置
我正在使用表格視圖並使用不同的單元格大小,但是當我刪除單元格時,它顯示在常量位置上,而不是在單元格中間。我應該爲自定義刪除按鈕位置做些什麼?在UITABLE VIEW中更改刪除按鈕的位置
這是真的哈克,但我發現這個代碼片斷而回:
- (void)willTransitionToState:(UITableViewCellStateMask)state {
[super willTransitionToState:state];
if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
subview.hidden = YES;
subview.alpha = 0.0;
}
}
}
}
- (void)didTransitionToState:(UITableViewCellStateMask)state {
[super willTransitionToState:state];
if (state == UITableViewCellStateShowingDeleteConfirmationMask || state == UITableViewCellStateDefaultMask) {
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
UIView *deleteButtonView = (UIView *)[subview.subviews objectAtIndex:0];
CGRect f = deleteButtonView.frame;
f.origin.x -= 20;
deleteButtonView.frame = f;
subview.hidden = NO;
[UIView beginAnimations:@"anim" context:nil];
subview.alpha = 1.0;
[UIView commitAnimations];
}
}
}
}
基本上,你是在剝離子視圖,直到找到刪除按鈕。我還建議不顯示默認的刪除按鈕,並使用您自己的自定義刪除按鈕。
重新載入表viewWillAppear
。它將在記錄被刪除後重新加載表格。
[super viewWillAppear:animated];
// [self.tableView reloadData ];
[tblSimpleTable reloadData];
aft刪除按鈕你只是重新加載tableview! – 2011-03-10 11:13:17