向TableViewCell添加Popover
问题描述:
我一直在为此苦苦挣扎,并希望任何人都可以阐明为什么这不起作用。向TableViewCell添加Popover
我只是试图在TableViewCell上实现一个Popover。这里是代码..
TodoView.m
- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event {
// MyViewController is a TUIViewController with a nib called MyView with just a button in it
MyViewController *t = [[MyViewController alloc] initWithNibName:@"MyView" bundle:nil];
TUIView *theView = [[TUIView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300)];
TUIPopover *myPopover = [[TUIPopover alloc] initWithContentViewController:t];
[myPopover showRelativeToRect:NSMakeRect(0, 0, 300, 300) ofView:theView preferredEdge:NSMaxYEdge];
}
有一段时间,什么都不会显示出来。我可以告诉一些事情正在发生,因为窗口本身会失去焦点,就好像一个Popover 在那里是。
有时我会看到一个非常小的blip-像2px×2px的小矩形。很难看到它,看起来像屏幕上的坏点,但有时候我会运行这段代码。
TUIPopover来自Twitter UIKit Framework。
一些可能性...
1)酥料饼不能被看到在CGFillRect?
TodoTableViewCell.m
- (void)drawRect:(CGRect)rect
{
CGRect b = self.bounds;
CGContextRef ctx = TUIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 247.0/255, 247.0/255, 247.0/255, 1);
CGContextFillRect(ctx, b);
}
2)酥料饼不适合TableViewCell内,不能被看作
任何人有什么想法?
答
真正简单的答案:
我忘了设定的酥料饼的内容大小!
因此,对于任何想知道为什么他们的弹出不起作用的人,请确保设置了内容大小!
TUIPopover *p = [[TUIPopover alloc] initWithContentViewController:commentsViewController];
[p setAnimates:TRUE];
[p setContentSize:CGSizeMake(300, 350)];
[p setBehaviour:TUIPopoverViewControllerBehaviourTransient];
[p showRelativeToRect:b.bounds ofView:b preferredEdge:CGRectMinYEdge];