0

I have a scroll view, and when a user moves from one imageview to the next, I want the title in the navigation bar to change. So I want to set a new title for the navigation bar for each image in the scroll view. How would I go about doing this?

Thank you very much for your help.

user1072337
  • 12,615
  • 37
  • 116
  • 195

1 Answers1

0

Write a delegate for your scroll view. In the delegate, implement the scrollViewDidScroll: method to figure out which image is currently visible and change the title.

To eliminate your incompatible type warning, you can declare that ScrollViewController adopts the UIScrollViewDelegate protocol:

@interface ScrollViewController : UIViewController <UIScrollViewDelegate>
rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • Hey Rob, as a test, I set up the method: - (void)scrollViewDidScroll:(UIScrollView *)scrollView1 { int Position = (scrollView1.contentOffset.x); if (Position == 0) { NSLog(@"Data 1"); } else if (Position == 320) { NSLog(@"Data 2"); }} in my scrollview.m file. Then in viewDidLoad I used the command: scrollView.delegate = self; This appears to be working, however, I am receiving a soft error (yellow exclamation mark), that reads: Passing "Scroll View Controller" *const_strong' to parameter of incompatible type 'id'. – user1072337 Dec 11 '11 at 01:11
  • You can edit your question to include your code, instead of putting it in a comment. I have edited my answer to explain how to eliminate the warning. – rob mayoff Dec 11 '11 at 02:22