iOS:Tapku日历库 - 允许为当前月份选择多个日期 [英] iOS: Tapku calendar library - allow selecting multiple dates for current month

查看:532
本文介绍了iOS:Tapku日历库 - 允许为当前月份选择多个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Tapku 库执行日历。我可以看到有一种方法可以添加 标记 ,但我希望允许用户从当前月份选择/取消选择任意数量的日期,并希望为每个操作生成事件。



此外,我已关闭月导航功能,返回nil为左和右箭头仅显示当前月份,但无法删除几个上个月和下个月的事件在当前月份显示的日期图块。我仍然可以选择上个月的第31天导航到上一个月或选择下个月的第1个导航到下个月。我可以将日期选择限制为只有当前月份吗?



谢谢。

解决方案>

触摸操作在 TKCalendarMonthView.m 中以以下方法处理:

   - (void)reactToTouch:(UITouch *)touch down:(BOOL)down 

查看第563行的块:

  if(portion == 1)
{
selectedDay =天;
selectedPortion = part;
[target performSelector:action withObject:[NSArray arrayWithObject:[NSNumber numberWithInt:day]]];
}
else if(down)
{
//这是你的重要组成部分。
//通过在这里添加return来忽略它(或删除以下三行)
return;
[target performSelector:action withObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:day],[NSNumber numberWithInt:part],nil]];
selectedDay = day;
selectedPortion = part;
}

选择/取消选择可能不会按预期工作。它不像 setDateSelected setDateDeselected ..而是有一个 UIImageView * ,表示选择的状态。该视图移动到当前位置。你可以在代码中搜索 self.selectedImageView ,看看发生了什么。



以引入多日期选择。该架构不是为此而建的。


I am using Tapku library for calendar implementation. I could see that there is a way to add Markers for predefined start and end date but I want to allow users to select/unselect any number of dates from current month only, and want to generate event for each action.

Moreover, I have switched off the month navigation functionality by returning nil for Left and Right arrow to display only current month but not able to remove events for few previous and next months Date tiles that gets displayed on current month. I can still select previous month's day 31st to navigate to previous month or select 1st on next month to navigate to next month. Can I restrict the date selection to only current month please?

Thanks.

解决方案

The touches are handled in TKCalendarMonthView.m in the following method:

- (void) reactToTouch:(UITouch*)touch down:(BOOL)down

look at the block at row 563:

if(portion == 1)
{
    selectedDay = day;
    selectedPortion = portion;
    [target performSelector:action withObject:[NSArray arrayWithObject:[NSNumber numberWithInt:day]]];
}
else if(down)
{
    // this is the important part for you.
    // ignore it by adding a return here (or remove the following three lines)
    return;
    [target performSelector:action withObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:day],[NSNumber numberWithInt:portion],nil]];
    selectedDay = day;
    selectedPortion = portion;
}

The selecting/deselecting perhaps doesn't work as you expect. It's not like setDateSelected and setDateDeselected.. instead there is a single UIImageView*, which represents the selected state. And that view is moved around to the current position. You can search for self.selectedImageView in the code to see, what is happening.

So its not that easy to introduce multiple-date-selection. The architecture isn't built for that.

这篇关于iOS:Tapku日历库 - 允许为当前月份选择多个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆