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