【问题标题】:CustomView(UITableView) after hiding have to access the UITextFields under Customview area [closed]隐藏后的CustomView(UITableView)必须访问Customview区域下的UITextFields [关闭]
【发布时间】:2013-02-22 07:11:01
【问题描述】:

UITextField 开始编辑时,我收到UITableView,在我的功能完成后将其隐藏。

我采用了静态UITableView。我的问题是隐藏UITableView(CustomView) 之后我无法访问UITextFields 下方(在UITableView 区域中)

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
        if(textField==CompanyName)
        {
            autocompleteTableView.hidden = NO;
                NSString *substring = [NSString stringWithString:textField.text];
                substring = [substring stringByReplacingCharactersInRange:range withString:string];
                [self searchAutocompleteEntriesWithSubstring:substring];
                return YES;
                if([CompanyName.text length]==0)
                {
                    autocompleteTableView.hidden = YES;

                }
        }


        if([arr4 count]!=0)
        {
            self.autocompleteUrls = [[[NSMutableArray alloc] init]autorelease];
            viewForautoCompleteTableView = [[UIView alloc]initWithFrame:CGRectMake(10, 110, 195, 230)];

            if(autocompleteTableView)
                [autocompleteTableView removeFromSuperview];

            autocompleteTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,195,150) style:UITableViewStyleGrouped];
            autocompleteTableView.delegate = self;
            autocompleteTableView.dataSource = self;
            autocompleteTableView.scrollEnabled = YES;
            autocompleteTableView.backgroundColor = [UIColor lightTextColor];
            autocompleteTableView.rowHeight=28;

            autocompleteTableView.backgroundView = nil;
            autocompleteTableView.backgroundColor = [UIColor whiteColor];


            autocompleteTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
            [autocompleteTableView setSeparatorColor:[UIColor orangeColor]];
            [viewForautoCompleteTableView setFrame:CGRectMake(10,110 ,195,autocompleteTableView.frame.size.height)];


            [viewForautoCompleteTableView addSubview:autocompleteTableView];
            [self.view addSubview:viewForautoCompleteTableView];

            [autocompleteUrls removeAllObjects];
            for(int i=0;i<[arr4 count];i++)
            {
                NSString *curString = [[arr4 objectAtIndex:i] valueForKey:@"Name"];
                [autocompleteUrls addObject:curString];

            }
        }
    [autocompleteTableView reloadData];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(currentHtmlElement==@"5")
    {
        UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
        CompanyName.text = selectedCell.textLabel.text;
        autocompleteTableView.hidden=YES;
    }
}

【问题讨论】:

  • 你能告诉我你的代码吗?
  • 粘贴代码...一旦隐藏的文本字段对用户不可见,因此您必须尝试访问之前编写的一些值,然后将它们保存
  • 在 uiView 中而不是在 UITableView 中添加您的 UITextField
  • 如果您没有发布任何代码,我将无法解决您的问题。您的问题我很难理解。
  • @prathyusha 请将您的项目上传到github,或者发送到我的邮箱。我会在更正后回复您。很难理解您在做什么。

标签: iphone uitableview xcode4.5


【解决方案1】:

添加 textField 委托如下: 可能会对你有所帮助..

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    [self.view bringSubviewToFront:btnuserLocation];
    autocompleteTableView.hidden=true;
}

对于 UIbutton 的按钮更改控制事件从 UIControlEventTouchDown 到 UIControlEventTouchUpInside 如下所示:

[btnuserLocation addTarget:self
                    action:@selector(showLocation:)
                forControlEvents:UIControlEventTouchUpInside];

当焦点从你的 textField 中移除时,它会隐藏你的表格视图。并让你点击 tableView 后面的按钮。

【讨论】:

  • 谢谢你的帮助。但它只适用于某些页面。
  • 我在您的 gmail 中发布了一个问题。请检查您的邮件
  • 你的意思是选择器箭头不起作用
  • 不,选择器箭头正在工作,选择器确实选择行不起作用
  • 我检查了这里一切正常,但速度很慢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-26
  • 1970-01-01
  • 1970-01-01
  • 2011-05-08
  • 2020-06-10
  • 1970-01-01
相关资源
最近更新 更多