我有一个UITableView,你可以点击细胞。 当您点击时,会运行一些操作,但在此上下文中这并不重要。我第一次按,它正确处理水龙头。第二次运行代码,但所有View更新(如显示UIAlertView或显示新视图)都会延迟。但不是因为时间而延迟 - 它等着我触摸屏幕。无论我在哪里或等待多久,我都要按。它每次都是第一次。
我的TableView设置为单选,不显示触摸选择。任何想法为什么这样做?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell isKindOfClass:[DetailTableViewCell class]]) {
DetailTableViewCell *detailCell = (DetailTableViewCell *)cell;
NSString *hourString = [detailCell hourString];
if (!detailCell.booking) {
NSDate *rightNow = [NSDate new];
NSDate *cellDate = [self.currentDate dateWithHour:indexPath.row andMinutes:0];
// Only allow future bookings (but allow people people to book within the hour)
if([rightNow compare:[cellDate nextHour]] == NSOrderedAscending){
[self performSegueWithIdentifier:@"roomBooking" sender:indexPath];
return;
} else {
[[[UIAlertView alloc] initWithTitle:@"Error" message:@"We currently do not allow our users make bookings in the past" delegate:nil cancelButtonTitle:@"Gotcha" otherButtonTitles:nil] show];
return;
}
} else if ([detailCell.booking hasPhoneNumber]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%ld",(long)[detailCell.booking telephone]]]];
return;
} else {
//TODO: FIND OUT IF BOOKING IS OWNED BY THE CURRENT USER
[[[UIAlertView alloc] initWithTitle:@"Booking"
message:[NSString stringWithFormat:@"You are now removing the booking at %@.", hourString]
delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
@weakify(self);
[self.room removeBookingWithId:[detailCell.booking.bookingId integerValue] andCompletion:^(BOOL success, NSError *error) {
@strongify(self);
if (success) {
@weakify(self);
[self.room.location updateBookingsWithCompletion:^(BOOL success, NSError *error) {
@strongify(self);
if (success) {
[self.calendar reloadData];
}
}];
}
}];
return;
}
}
}
答案 0 :(得分:1)
SelectionStyle设置为None,但我们将其更改为其他内容,这解决了问题。
单击TableViewCell本身。 在您的属性部分中找到:“选择” 设置为:蓝色/灰色/默认。