I am trying to create an app with a built in chat feature. I am trying to make it work similarly to the Messages application, with one major difference. Instead of there being a camera icon for MMS I would like to add a UISegmentedControl to manually switch between which person you are in the conversation. I have it working pretty well except whenever you change identity on the switch, it changes the identity of everything said previously in the chat. I'm really stuck up on this and any help would be greatly appreciated.
NSString *text = [messages objectAtIndex:indexPath.row];
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:14.0] constrainedToSize:CGSizeMake(240.0f, 480.0f) lineBreakMode:UILineBreakModeWordWrap];
UIImage *balloon;
if(segmentedControl.selectedSegmentIndex == 0) {
balloonView.frame = CGRectMake(320.0f - (size.width + 28.0f), 2.0f, size.width + 28.0f, size.height + 15.0f);
balloon = [[UIImage imageNamed:@"green.png"] stretchableImageWithLeftCapWidth:24 topCapHeight:15];
label.frame = CGRectMake(307.0f - (size.width + 5.0f), 8.0f, size.width + 5.0f, size.height);
}
else if(segmentedControl.selectedSegmentIndex == 1) {
balloonView.frame = CGRectMake(0.0, 2.0, size.width + 28, size.height + 15);
balloon = [[UIImage imageNamed:@"grey.png"] stretchableImageWithLeftCapWidth:24 topCapHeight:15];
label.frame = CGRectMake(16, 8, size.width + 5, size.height);
}
balloonView.image = balloon;
label.text = text;
return cell;
}
-(IBAction) segmentedControlIndexChanged {
switch (self.segmentedControl.selectedSegmentIndex)
{
case 0: (self.segmentedControl.selectedSegmentIndex == 0);
case 1: (self.segmentedControl.selectedSegmentIndex == 1);
break;
default:
break;
}
}
So over all, what I'm asking is how can I modify this, to make it so when i switch the UISegmentedControl it changes the messages typed while the switch is in this state only. Thank you in advance!