我对FPPopover库的实现有疑问。
我遇到的问题与其他帖子类似:Same issue on StackOverFlow
不幸的是,对popover控制器的引用并不能解决我的问题。
在我未来的控制器上,单击操作按钮时会动态加载UITableView。这是我的代码:
- (IBAction)displayAlternateNicknames:(id)sender{
PXAlternativeNicknamesViewController * suggestionsVC= [[UIStoryboard storyboardWithName:[ViewsParamsSingleton sharedLoginSignUpStoryBoard] bundle:nil] instantiateViewControllerWithIdentifier:NicknameSuggestionsStoryBoardID];
suggestionsVC.title=@"Suggestions";
suggestionsVC.nicknameSuggestions=self.nicknameSuggestions;
suggestionsVC.callerVC=self;
//our popover
suggestionsPopover = [[FPPopoverController alloc] initWithViewController:suggestionsVC];
suggestionsPopover.contentSize = CGSizeMake(200,200);
//the popover will be presented from the okButton view
[suggestionsPopover presentPopoverFromView:sender];
}
答案 0 :(得分:0)
这是我在生产中工作的实施。试试吧。可能只是你没有正确设置所有属性。
// MyViewController.m
@interface MyViewController ()
@property(nonatomic, strong) FPPopoverController *popover;
@end
...
// Instantiate popover
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
LoginViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
if (self.popover) {
[self.popover dismissPopoverAnimated:NO];
self.popover = nil;
}
self.popover = [[FPPopoverController alloc] initWithViewController:viewController];
self.popover.contentSize = viewController.size;
self.popover.border = NO;
self.popover.arrowDirection = FPPopoverNoArrow;
self.popover.tint = FPPopoverRedTint;
[self.popover presentPopoverFromView:self.loginButton];
如果问题仍然存在,我找到了另一个可能有帮助的答案here。基本上,您必须为FPPopover禁用ARC。我不确定如何使用Cocoapods这样做,因此您可能只需将库直接复制并粘贴到项目中。我知道这不是一个理想的解决方案,但我认为它值得一试。
另一种可能性是创建FPPopover的实例变量并以这种方式引用它。例如:
@property (nonatomic, strong) FPPopover *popover;
...
- (FPPopover *)popover {
if(!_popover){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
LoginViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
_popover.contentSize = viewController.size;
_popover.border = NO;
_popover.arrowDirection = FPPopoverNoArrow;
_popover.tint = FPPopoverRedTint;
}
return _popover;
}
...
-(void)buttonTapped:(UIButton *)sender{
[self.popover presentPopoverFromView:sender];
}