【问题标题】:Why can't I see the text when I type in a UITextField embedded in a UIPopover?为什么我在输入嵌入在 UIPopover 中的 UITextField 时看不到文本?
【发布时间】:2013-08-03 04:25:48
【问题描述】:

我有一个 iPad 应用程序(XCode 4.6、ARC、Storyboards),当用户点击 UIButton 时,我希望在其中显示带有 UITextField 的弹出框。

弹出框出现,键盘出现,但 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];

【问题讨论】:

  • 小子,那一口咬我!当我做这样的事情时,我只是讨厌它......你能删除你的评论并重新做一个答案吗?谢谢... :D

标签: ios6 uitextfield xcode4.6 uipopover


【解决方案1】:

文本字段应该用

创建
UITextField *tf = [[UITextField alloc] initWithFrame:...]

指定字段的来源和大小。

【讨论】:

    猜你喜欢
    • 2019-05-18
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-01
    相关资源
    最近更新 更多