弹出窗口中的UIReferenceLibraryViewController [英] UIReferenceLibraryViewController in a popover
本文介绍了弹出窗口中的UIReferenceLibraryViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果搜索到某个单词,我会使用这部分代码来提取字典:
I have this portion of code to pull up the dictionary if a word is searched:
- (IBAction)searchButtonPressed:(id)sender
{
NSString *searchTerm = self.searchTextField.text;
if([UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:searchTerm])
{
UIReferenceLibraryViewController *referenceLibraryVC = [[UIReferenceLibraryViewController alloc] initWithTerm:searchTerm];
[self presentModalViewController:referenceLibraryVC animated:NO];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Word not found" message:@"no definition" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
然而,它似乎只适用于主视图在xib中,涵盖了更加迷人的iPad屏幕。我怎样才能获得它只在子视图中打开,只是屏幕的一部分?
however, it only seems to work on the main view in the xib and covers the entier iPad screen. How can I get it so that it only opens up in a subview, just a portion of the screen?
推荐答案
使用 UIPopoverController
,就像它在本机应用程序中使用一样。
Use a UIPopoverController
, like it is used in native applications.
self.popover = [[UIPopoverController alloc] initWithContentViewController:referenceLibraryVC];
[self.popover presentPopoverFromRect:[sender frame] inView:[sender superview] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
您将需要保留弹出控制器,直到它被解除。设置代理,你可以在它被解雇时收听,这样你就可以释放它。
You will need to retain the popover controller until it is dismissed. Set the delegate and you can listen when it is dismissed so you can release it.
这篇关于弹出窗口中的UIReferenceLibraryViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文