2014-01-15 3 views
-1

Я хочу показать всплывающее окно с календарем, когда пользователь нажмет кнопку. Я видел много всплывающих окон, но они не включают стрелку с нажатой кнопки. Я хочу что-то похожее на изображение ниже. Я сделал календарь, и я не знаю, как вставить его в popover. Может кто-нибудь дать мне трюк?popover calendar, когда пользователь нажимает кнопку

Я знаю, как сделать popover с табличным представлением, но нет с другим диспетчером представлений.

Спасибо!

enter image description here

+0

Этот сайт предназначен для вопросов, а не просто для того, чтобы сообщать нам, что вы хотите. – rmaddy

+0

@rmaddy Хорошо, мой вопрос в том, что я не знаю, как поместить календарь в popover, есть ли кто-нибудь, кто знает, как это сделать? У меня есть календарь, о чем я прошу, так это о том, как поместить его в popover. Извините, если мой вопрос кажется, что я прошу людей сделать свою работу, потому что это не так. –

+0

Создание 'UIPopoverController' с другим контроллером представления - это то же самое, что создать файл с табличным представлением. Popover всегда создается с другим контроллером представления. Покажите, что вы пытались сделать, чтобы создать popover с вашим календарем. – rmaddy

ответ

0

я решил мою проблему. Я собираюсь объяснить, шаг за шагом:

1- Прежде всего я создал поповер 2- Тогда я должен включать в себя calendar к моему проекту 3- Тогда я должен добавить вид календаря в пирог

Вот код:

- (IBAction)startPressed:(id)sender { 

UIButton * popoverButton = (UIButton*) sender; 

CKCalendarView *calendar = [[CKCalendarView alloc] initWithStartDay:startMonday]; 
self.calendar = calendar; 
calendar.delegate = self; 

self.dateFormatter = [[NSDateFormatter alloc] init]; 
[self.dateFormatter setDateFormat:@"dd/MM/yyyy"]; 
self.minimumDate = [self.dateFormatter dateFromString:@"20/09/2012"]; 

self.disabledDates = @[ 
         [self.dateFormatter dateFromString:@"05/01/2013"], 
         [self.dateFormatter dateFromString:@"06/01/2013"], 
         [self.dateFormatter dateFromString:@"07/01/2013"] 
         ]; 

calendar.onlyShowCurrentMonth = NO; 
calendar.adaptHeightToNumberOfWeeksInMonth = YES; 
calendar.tag = 0; 

calendar.frame = CGRectMake(10, 10, 300, 320); 

self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(calendar.frame) + 4, self.view.bounds.size.width, 24)]; 
[self.view addSubview:self.dateLabel]; 

self.view.backgroundColor = [UIColor whiteColor]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(localeDidChange) name:NSCurrentLocaleDidChangeNotification object:nil]; 


popoverContent = [[UIViewController alloc] 

            init]; 

UIView* popoverView = [[UIView alloc] 

         initWithFrame:CGRectMake(0, 0, 300, 220)]; 

popoverView.backgroundColor = [UIColor whiteColor]; 

popoverContent.view = calendar; 


//resize the popover view shown 
//in the current view to the view's size 

popoverContent.contentSizeForViewInPopover = 

CGSizeMake(300, 220); 


//create a popover controller 

self.myPopover = [[UIPopoverController alloc] 

          initWithContentViewController:popoverContent]; 


//present the popover view non-modal with a 
//refrence to the button pressed within the current view 
//UIPopoverArrowDirectionAny 
[self.myPopover presentPopoverFromRect:popoverButton.frame 

             inView:self.view 

         permittedArrowDirections:UIPopoverArrowDirectionUp 

             animated:YES]; 

}

Вот самая важная часть кода. Если кто-то хочет помочь, не сомневайтесь в этом!

Смежные вопросы