我有一个iPad应用程序(XCode 4.6,ARC,Storyboards),当用户点击UIButton时,我想要一个带有UITextField的popover。
出现弹出框,键盘出现,但UITextField中没有任何内容。我错过了什么?
以下是代码:
// make the popover
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 450, 500)];
popoverView.backgroundColor = [UIColor colorWithWhite:(CGFloat)1.0 alpha:(CGFloat)1.0]; // frame color?
popoverContent.view = popoverView;
//resize the popover view shown in the current view to the view's size
popoverContent.contentSizeForViewInPopover = CGSizeMake(450, 500);
// add the UITextfield to the popover
UITextField *tf = [[UITextField alloc]init];
[tf becomeFirstResponder];
[popoverView addSubview:tf];
//create a popover controller
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
[popoverController presentPopoverFromRect:((UIButton *)oSendFeedback).frame inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
答案 0 :(得分:1)
应使用
创建文本字段UITextField *tf = [[UITextField alloc] initWithFrame:...]
指定字段的来源和大小。