2014-12-08 110 views
1

我使用的XCode 6.1出示酥料餅,我不有「酥料餅」選項。我的配置有問題嗎?這是正常的嗎?他們刪除了它嗎?我現在如何展示popover?如何用故事板僅

這是iPhone的發展,而不是iPad的。

the small view controller is to become the popover

+0

我想你必須改變模擬指標到iPad – MendyK 2014-12-08 01:33:37

+0

你是什麼意思?我正在開發iPhone。 – 2014-12-08 01:39:17

回答

1

從文檔(https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPopoverController_class/index.html

酥料餅的控制器是隻在iPad設備使用。 試圖在其他設備上創建一個會導致異常。

如果你想使用類似popover的東西,你將不得不爲它使用第三方代碼。

+0

是否有替代選擇iphones?我只想在同一屏幕上彈出一個uipicker。我必須使用新的UIViewController? – 2014-12-08 01:49:01

+0

你可以添加一個UIPickerView到你的ViewController的主視圖。也許從屏幕底部或其他東西在屏幕上進行動畫處理。 – 2014-12-08 01:51:00

0

正如丹尼爾在他的文章中說,UIPopoverController對象僅僅是iPad的。

有跡象表明,給你同樣的外觀和感覺上的iPhone第三方庫。我沒有具體的一個指向你,但看看Github。

1

您創建一個UIView任何你想要的,並選擇啓動它像相同的感覺:

就拿這張照片例如:

enter image description here

視圖可以做出這樣的,通知filterView被添加到超級視圖,因爲我已經將視圖的userInteractionEnabled設置爲NO,因此用戶必須在繼續使用視圖之前選擇一個選項,但是,它是可選的,我只是指出它:

self.view.userInteractionEnabled = NO; 
    [self.navigationItem.rightBarButtonItem setEnabled:NO]; 
self.filterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)]; 
float X_CO = (self.view.superview.bounds.size.width - self.filterView.frame.size.width)/2; 
float Y_CO = (self.view.superview.bounds.size.width - self.filterView.frame.size.height)/2; 
[self.filterView setFrame:CGRectMake(X_CO, Y_CO + 75, 150, 150)]; 
self.filterView.backgroundColor = [UIColor whiteColor]; 
self.filterView.layer.borderColor = [UIColor lightGrayColor].CGColor; 
self.filterView.layer.borderWidth = 1.0f; 
self.filterView.layer.cornerRadius = 8.0f; 
self.filterView.layer.shadowColor = [UIColor blackColor].CGColor; 
self.filterView.layer.shadowOpacity = 0.5f; 
self.filterView.layer.shadowOffset = CGSizeMake(0, 1); 
self.filterView.layer.masksToBounds = NO; 

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 50)]; 
titleLabel.textAlignment = NSTextAlignmentCenter; 
titleLabel.text = @"Select Filter Option:"; 
titleLabel.font = [UIFont fontWithName:@"Eurostile" size:13]; 
titleLabel.textColor = [UIColor colorWithRed:48/255 green:131/255 blue:251/255 alpha:1]; 
[self.filterView addSubview:titleLabel]; 

self.azButton = [[UIButton alloc] initWithFrame:CGRectMake(10,self.filterView.frame.origin.y/3.5,30, 30)]; 
[self.azButton setBackgroundColor:[UIColor whiteColor]]; 
[self.azButton addTarget:self action:@selector(filterButton:) forControlEvents:UIControlEventTouchUpInside]; 
self.azButton.layer.borderColor = [UIColor lightGrayColor].CGColor; 
self.azButton.layer.cornerRadius = 15.0f; 
self.azButton.layer.borderWidth = 1.0f; 
[self.filterView addSubview:self.azButton]; 

UILabel *azLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.azButton.frame.origin.x + 40, self.azButton.frame.origin.y, 95, 30)]; 
azLabel.textAlignment = NSTextAlignmentLeft; 
azLabel.text = @"A-Z Sort"; 
azLabel.textColor = [UIColor blackColor]; 
azLabel.font = [UIFont fontWithName:@"Eurostile" size:20]; 
[self.filterView addSubview:azLabel]; 

self.zaButton = [[UIButton alloc] initWithFrame:CGRectMake(10, self.azButton.frame.origin.y + 40,30, 30)]; 
[self.zaButton setBackgroundColor:[UIColor whiteColor]]; 
[self.zaButton addTarget:self action:@selector(filterButton:) forControlEvents:UIControlEventTouchUpInside]; 
self.zaButton.layer.borderColor = [UIColor lightGrayColor].CGColor; 
self.zaButton.layer.cornerRadius = 15.0f; 
self.zaButton.layer.borderWidth = 1.0f; 
[self.filterView addSubview:self.zaButton]; 

UILabel *zaLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.azButton.frame.origin.x + 40, self.zaButton.frame.origin.y, 95, 30)]; 
zaLabel.textAlignment = NSTextAlignmentLeft; 
zaLabel.text = @"Z-A Sort"; 
zaLabel.textColor = [UIColor blackColor]; 
zaLabel.font = [UIFont fontWithName:@"Eurostile" size:20]; 
[self.filterView addSubview:zaLabel ]; 

[self.view.superview addSubview:self.filterView]; 

您可以添加背景圖片有酥料餅的視圖效果。

然後把它在用戶觸摸的點。

只是一個例子是:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
[super touchesBegan:touches withEvent:event]; 
UITouch *touch = [touches anyObject]; 
if ([touch.view isKindOfClass: UITableView.class]) { 
    //your touch was in a UITableView ... do whatever you have to do 
} 
} 

,然後做同樣的touchesEnded:還有許多其他的方式然而,去了解它。 (即找到確切的聯繫點等等,但這取決於你)

正如Duncan C指出的那樣,還有其他免費可用的框架可供使用。

當然,雖然,你總是可以在故事板或XIB創建它,這麼多的選擇

0

你應該可以看到這個當您按住Control鍵拖動到你的第二個VC:

enter image description here

當你選擇 「酥料餅的演講」,所產生的SEGUE應該是這樣的:

enter image description here

此選項應該一定適用於iPhone,並且您應該看到它。如果沒有,您的項目設置中可能會有些不妥之處。

但是,需要注意的是,這與使用UIPopoverController並不相同。相反,它調用了iOS 8中的新功能UIPopoverPresentationController(我相信)。適用於iPhone,不需要第三方框架。我目前正在iPhone項目中成功使用它,所以我知道它的工作原理。

我相信@Daniel T.的答案雖然在早期版本中是正確的,但已經被UIPopoverPresentationController過時了。