我有一个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;
}
}
}
SelectionStyle设置为None,但是我们将其更改为其他名称,从而解决了该问题。
单击TableViewCell本身。在属性部分中,找到:“选择”设置为:蓝色/灰色/默认。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句