Reputation: 3885
I need to implement a view that acts as a log view, so that when you push a message into it, the message would push other messages upwards. Is there anything like that for iOS?
Upvotes: 2
Views: 78
Reputation: 130212
@Vladimir's answer is probably the way to go, but just for the sake of seeing some additional options, here's an example using a UITextView:
- (IBAction)addNewLog:(UIButton *)sender {
NSString *myInputText = @"some new text from string";
NSString *temp = myTextView.text;
[myTextView setText:[temp stringByAppendingString:[NSString stringWithFormat:@"\n%@: %@",[NSDate date],myInputText]]];
[myTextView setContentOffset:CGPointMake(0, myTextView.contentSize.height - myTextView.frame.size.height) animated:NO];
}
Then if you wanted to separate the text in the text view into objects in an array:
NSArray *myAwesomeArray = [myTextView.text componentsSeparatedByString:@"\n"];
Mind you, the above would break if the "myInputText" string ever contained a line break.
Upvotes: 1
Reputation: 170859
You can easily implement that using standard UITableView:
scrollToRowAtIndexPath:atScrollPosition:animated:
method with UITableViewScrollPositionBottom
position parameter)That means you'll need to store your log messages in array, but if you're going to display them you need to store messages anyway
Upvotes: 3