Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 标记逻辑,如目标c中的WhatsApp_Objective C - Fatal编程技术网

Objective c 标记逻辑,如目标c中的WhatsApp

Objective c 标记逻辑,如目标c中的WhatsApp,objective-c,Objective C,我正在尝试在Objective-C中制作聊天应用程序 在本文中,我想实现像WhatsApp一样的标记 当用户在组中输入@时,应显示组成员列表。 我尝试这样做,但有时在输入退格后遇到问题,例如“@xyz”。我没有得到预期的输出 你能给我看一些例子或教程,我可以作为参考。简单地试一下 - (void)viewDidLoad { [super viewDidLoad]; textViews.delegate = self; namesArray = @[@"John",@"M

我正在尝试在Objective-C中制作聊天应用程序

在本文中,我想实现像WhatsApp一样的标记

当用户在组中输入@时,应显示组成员列表。 我尝试这样做,但有时在输入退格后遇到问题,例如“@xyz”。我没有得到预期的输出

你能给我看一些例子或教程,我可以作为参考。

简单地试一下

- (void)viewDidLoad {
    [super viewDidLoad];

    textViews.delegate = self;
    namesArray = @[@"John",@"Mathew”,@“iOS”];
    membersTable.hidden = true;

    // Do any additional setup after loading the view, typically from a nib.
}

- (void)textViewDidChange:(UITextView *)textView { // Delegate method called when any text is modified

    if ([textViews.text isEqualToString: @""]) {

        membersTable.hidden = true;
    }else{

        if ([[textView.text substringFromIndex: [textView.text length] - 1] isEqualToString:@"@"]) {
            NSLog(@"Success");
            membersTable.hidden = false;
        }else{
            membersTable.hidden = true;
        }
    }

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return namesArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [membersTable dequeueReusableCellWithIdentifier:@"cell"];
    cell.textLabel.text =[namesArray objectAtIndex:indexPath.row];

    return cell;
}

当用户在文本视图中输入“@”符号时,成员表视图将显示,然后用户可以通过选择表视图来选择成员

欢迎使用StackOverflow。请先看一看