2014-12-08 3 views
1

Xcode 6.1을 사용하고 있는데 "popover"옵션이 없습니다. 구성에 문제가 있습니까? 이게 정상인가? 그들이 그것을 제거 했습니까? 지금 팝업을 어떻게 표시합니까?스토리 보드를 사용하여 팝업을 표시하는 방법

이것은 iPhone 개발 용이며 iPad가 아닙니다. 문서에서

the small view controller is to become the popover

+0

시뮬레이션 된 메트릭을 iPad로 변경해야한다고 생각합니다. – MendyK

+0

무엇을 의미합니까? 나는 iPhone 용으로 개발 중이다. –

답변

1

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

팝 오버 컨트롤러는 전용 아이 패드 장치에 사용하기위한 것입니다. 다른 장치에 장치를 만들려고하면 예외가 발생합니다.

popover와 같은 것을 사용하려면 제 3 자 코드를 사용해야합니다.

+0

아이폰을위한 다른 옵션이 있습니까? 난 그냥 같은 화면에 uipicker 팝업 싶어요. 반드시 새로운 UIViewController를 사용해야합니까? –

+0

당신은 단지 당신의 ViewController의 메인 뷰에 UIPickerView를 추가 할 수 있습니다. 어쩌면 바닥이나 무언가에서 화면 상에 애니메이션을 적용 할 수 있습니다. –

0

Daniel이 자신의 게시물에서 말했듯이, UIPopoverController 객체는 iPad에만 있습니다.

iPhone과 동일한 모양과 느낌을주는 타사 라이브러리가 있습니다. 나는 당신을 가리 키도록 특별한 것이 없지만 기스 웁을 살펴 봅니다.

예를 들어이 사진을 촬영 :

1

당신은 당신이 원하는 선택기는이 같은 느낌과 유사하기 시작했다 어쨌든에 UIView를 만들

enter image description here

뷰는 다음과 같이 만들 수 있습니다를 통지 뷰를 계속 사용하기 전에 userInteractionEnabled를 NO로 설정했기 때문에 filterView가 슈퍼 뷰에 추가되었지만 뷰를 계속 사용하기 전에 옵션을 선택해야만했습니다. 그러나 선택 사항입니다. 방금 지적했습니다.

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

그것을 만들 수 있습니다 때 컨트롤 드래그 두 번째 VC에 :

enter image description here

을 "팝 오버 프레젠테이션"을 선택, 결과 SEGUE는 다음과 같아야합니다

enter image description here

이 옵션은 iPhone에서 사용할 수 있어야하며 사용자는이를보아야합니다. 그렇지 않은 경우 프로젝트 설정에 문제가있을 수 있습니다.

그러나 이것은 UIPopoverController를 사용하는 것과 같지 않다는 점에 유의해야합니다. 대신 iOS 8의 새로운 기능인 UIPopoverPresentationController을 호출합니다 (필자는 믿습니다). iPhone에서 작동하며 타사 프레임 워크가 필요 없습니다. 현재 iPhone 프로젝트에서 성공적으로 사용하고 있으므로 작동하는 것으로 알고 있습니다.

@Daniel T.의 대답은 이전 버전에서 올바르지 만 UIPopoverPresentationController에서 사용되지 않는 것으로 나타났습니다.

관련 문제