making UIView scrollable

Discussion in 'iPhone/iPad Programming' started by sujithkrishnan, Jul 3, 2008.

  1. macrumors 6502

    Joined:
    May 9, 2008
    Location:
    Bangalore
    #1
    Hi all.


    I am having a drill-down menu with UITableViewController end menu is a UIViewController...

    In the last menu (UIViewController objet)..
    I do

    Code:
    [self.view addSubView:myFirstLabel];
    [self.view addSubView:mySmallImageView];
    [self.view addSubView:mySecondLabel];
    [self.view addSubView:myTextView];
    
    All these are going outside the screen bounds.... (however i can make them congested to fit in screen, but i dont prefer..)

    Problem is that the self.view is not scrollable..
    I want to make it scrollable so that i can scroll to see all the labels..
    (however the textview is scrollable by itself)

    By giving self.view's bounds greater that screen bounds is not making it scrollable...
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    I've not done any iPhone work so this may be well off, but in standard Cocoa you can't make a view scrollable on it's own: you have to use a scroll view to contain the view. They may have simplified this on the iPhone though. I do see reference to UIScrollView in places so I'd look at that...
     
  3. macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #3
    Instead of building a bunch of labels, use a Table View and create groups and cells on the table programatially... The more cells you create - instant scrolling!

    Take a look at the samples...
     
  4. macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #4
    ... and make sure you read the documentation on how to work with Tables and Cells - you need to make sure you implement the delegates they require to manage memory properly...
     
  5. thread starter macrumors 6502

    Joined:
    May 9, 2008
    Location:
    Bangalore
    #5
    Thanks...

    But how to accomodate textfields in tableviews ????
    We can change labels with cell.text, but for textfields??
    Also I face some problem with UIViewController - say its not aligning themselves to the bounds on rotating device... However the UITableviews are adjusting by themsleves..

    I wll follow the docs too for more info...by that time can u answer the above?
     
  6. macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #6

    You don't! Table cells can be edited...

    Look at: tableView:shouldEditTableColumn:row

    And check out the guide in the docs about Table View Programming... Check out some of the samples that use these delegates. Most of the basic code is all boilerplate. Just cut and paste from the examples, and it works!

    (your mileage may vary)
     
  7. macrumors 65816

    dgdosen

    Joined:
    Dec 13, 2003
    Location:
    Seattle
    #7
    I'm looking at this right now... You could have done this by adding a UIScrollView and supporting the UIScrollViewDelegate.

    I'm trying to figure out how to use the UIPageView control to allow horizontal scrolling between views, but then have vertical scrolling available in a subview on a single page of the page view.

    I can't get the scrolling notification to move down to the view. Is there a way to do that?
     

Share This Page