sud*_*udo 5 iphone cocoa-touch uitableview
我有一个 uitableview,它在点击单元格时实现弹出框( PopoverView ),然后弹出框将在屏幕上的任何其他点击时关闭。问题是,如果用户想要双击或重复点击单元格,它将导致显示多个 popoverviews 实例,然后应用程序将崩溃..我正在寻找一种方法来禁用双击单元格和/ 或UITableView一般或有没有办法延迟接触UITableViewCell任何想法?
我已经尝试过这个,但它在我的情况下不起作用。另一种方法是检查 PopoverView 是否已经存在,如果存在,则不允许另一个实例化。我试过这个和这个,在我的情况下都不起作用。
这是我调用 popover 视图的代码didSelectRowAtIndexpath:
- (void)tableView:(UITableView *)TableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [TableView cellForRowAtIndexPath:indexPath];
sti = [[SelectedTeamsInfo alloc] init];
MyLeagueStandings *info = [fetchedResultsController objectAtIndexPath:indexPath];
[sti getAllScheduleForTeam:info.urlforteam];
NSString *title = info.teamname;
// If title length is greater then 32 truncate it to fit.
if (title.length > 32) {
title = [info.teamname substringToIndex:29];
title = [title stringByAppendingString:@"..."];
}
[PopoverView showPopoverAtPoint:cell.center inView:self.view withTitle:title withContentView:sti.view delegate:self];
}
Run Code Online (Sandbox Code Playgroud)
解决方案:
在接口类中:
BOOL PopoverYN;
Run Code Online (Sandbox Code Playgroud)
在实现类中:
- (void)tableView:(UITableView *)TableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// If the popover is not available then display it else do nothing since one is already displayed.
if (PopoverYN == NO) {
PopoverYN = YES;
UITableViewCell *cell = [TableView cellForRowAtIndexPath:indexPath];
sti = [[SelectedTeamsInfo alloc] init];
MyLeagueStandings *info = [fetchedResultsController objectAtIndexPath:indexPath];
[sti getAllScheduleForTeam:info.urlforteam];
NSString *title = info.teamname;
// If title length is greater then 32 truncate it to fit.
if (title.length > 32) {
title = [info.teamname substringToIndex:29];
title = [title stringByAppendingString:@"..."];
}
[PopoverView showPopoverAtPoint:cell.center inView:self.view withTitle:title withContentView:sti.view delegate:self];
}
}
#pragma mark - popover methods.
- (void)popoverViewDidDismiss:(PopoverView *)popoverView;
{
PopoverYN = NO;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3192 次 |
| 最近记录: |