Search code examples
uiviewrssuiwebviewcore-animationuitextview

Scrolling RSS reader iPhone View


I'm planning on adding a small subview to the bottom of my current app so that it can display RSS feed headlines one at a time. What would be the best type of view to use for this? UITextView, UIWebView? Perhaps a custom UITableViewCell? If i use a UITextView and tap it, it displays the keyboard, but if i setUserInteractionEnabled to NO then i wont be able to launch a different view with the article...

Scrolling each block of text would be done using core animation right?

Thanks.


Solution

  • Use a UILabel. And yes, you will use Core Animation to animate. Here is a basic UIView animation block that will move a UILabel from the far right of the screen to the left.

    // Set your label to display offscreen to the right
    [feedLabel setCenter:CGPointMake(
                       screenWidth + [feedLabel bounds].size.width / 2, 
                       [feedLabel frame].origin.y)];
    
    // Then later animate it into view and then off to the left.
    [UIView beginAnimations:nil context:NULL];
    // Give it 10 seconds to make it all the way across.
    [UIView setAnimationDuration:10.0f];
    [feedLabel setCenter:CGPointMake(
                       0.0 - [feedLabel bounds].size.width / 2, 
                       [feedLabel frame].origin.y)];
    [UIView commitAnimations];
    

    Remember that the anchorPoint for a view such as a UILabel is the center of the view. This is why the call to -setCenter is taking half the width of the label to determine where the x coordinate should be. The y coordinate, of course, should just stay the same.