我有一个UIPopoverController
显示 aUIToolbar
和 aUICollectionViewController
的多个单元格。我看到的问题是集合视图出现在工具栏下方。
我试图移动集合视图控制器(通过更改其原点)将其移动到工具栏下方,但无济于事。
在屏幕截图中,我将工具栏设置为半透明,以便您了解我的意思。
我正在使用 iOS 6 SDK。
构成弹出框的元素是直截了当的。我有一个在我的自定义类UICollectionViewController
中创建的自定义。这里是来自该自定义类的代码——创建工具栏,然后将其与集合视图控制器 ( ) 一起添加:init
UIPopoverController
UIPopoverController
init
photosCollectionViewController
// init for the custom UIPopoverController derived class follows:
-(id)init
{
photosCollectionViewController = [[MyPhotosCollectionViewController alloc] init];
self = [super initWithContentViewController:photosCollectionViewController];
if (self) {
// I tried taking the contentViewController's frame and moving it down
// by adding TOOLBAR_HEIGHT to its y co-ordinate, but it does not work.
CGRect frame = self.contentViewController.view.frame;
UIToolbar *viewToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, TOOLBAR_HEIGHT)];
viewToolbar.barStyle = UIBarStyleBlackTranslucent;
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelTapped:)];
UIBarButtonItem *separator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
CGRect labelFrame = CGRectMake(viewToolbar.frame.origin.x, viewToolbar.frame.origin.y, 100, 20);
UIBarButtonItem *title = [[UIBarButtonItem alloc] initWithCustomView:[PANGraphicsHelper labelForToolbar:labelFrame text:@"Photos"]];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPhotopTapped:)];
viewToolbar.items = @[ cancelButton, separator, title, separator, addButton];
[self.contentViewController.view addSubview:viewToolbar];
_toolbar = viewToolbar;
// Make the popover large enough to hold the 3x3 collection view and the toolbar above
self.popoverContentSize = CGSizeMake(frame.size.width, frame.size.height + TOOLBAR_HEIGHT);
}
}