Apple缺少有關如何使用iOS5中引入的UIPopoverBackgroundView
類的文檔。任何人都有一個例子?使用UIPopoverBackgroundView類
我曾試圖繼承它,但我對獅子的XCode 4.2丟失UIPopoverBackgroundView.h
編輯:毫不奇怪,它應該被導入爲#import <UIKit/UIPopoverBackgroundView.h>
Apple缺少有關如何使用iOS5中引入的UIPopoverBackgroundView
類的文檔。任何人都有一個例子?使用UIPopoverBackgroundView類
我曾試圖繼承它,但我對獅子的XCode 4.2丟失UIPopoverBackgroundView.h
編輯:毫不奇怪,它應該被導入爲#import <UIKit/UIPopoverBackgroundView.h>
要添加到其他鏈接 - 只有答案,這是如何完成的。
聲明在你的界面如下:
+(UIEdgeInsets)contentViewInsets;
+(CGFloat)arrowHeight;
+(CGFloat)arrowBase;
@property(nonatomic,readwrite) CGFloat arrowOffset;
@property(nonatomic,readwrite) UIPopoverArrowDirection arrowDirection;
類的方法是簡單的:contentViewInsets
返回你的邊框的寬度一路輪(未包括箭頭),arrowHeight
是你箭頭的高度,arrowBase
是你箭頭的基礎。
[self setNeedsLayout]
。layoutSubviews
。在這裏,根據arrowDirection
和arrowOffset
屬性,您必須調整背景視圖和箭頭視圖的框架。
self.bounds
,通過arrowHeight
上任何邊緣上的箭頭位於arrowOffset
從self
中心向外(正確根據軸線)。如果箭頭方向沒有打開,你必須改變圖像方向,但是我的彈出只會彈起來,所以我沒有這樣做。這裏是我最多隻子類的layoutSubviews
方法:
-(void)layoutSubviews
{
if (self.arrowDirection == UIPopoverArrowDirectionUp)
{
CGFloat height = [[self class] arrowHeight];
CGFloat base = [[self class] arrowBase];
self.background.frame = CGRectMake(0, height, self.frame.size.width, self.frame.size.height - height);
self.arrow.frame = CGRectMake(self.frame.size.width * 0.5 + self.arrowOffset - base * 0.5, 1.0, base, height);
[self bringSubviewToFront:self.arrow];
}
}
另一個鏈接只能回答,但定製UIPopoverBackgroundView
更多的工作比你可能會意識到在有限的文檔信息,並將該github項目有一個完整的工作示例,爲我節省了大量的時間:https://github.com/GiK/GIKPopoverBackgroundView
放入您自己的項目相當簡單。最棘手的部分是適應你使用的任何自定義圖像的帽子插圖。我建議在項目中原位進行自定義設置,因爲在將模擬器遷移到自己的項目之前,可以很容易地驗證所有彈出方向/方向用例在模擬器中正確顯示。
確定找不到文檔?:http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIPopoverBackgroundView_class/Reference/Reference.html – CodaFi
也許看錯了SDK ? –
感謝#import :) –
Cesar