Newbie question iPad views

Discussion in 'iOS Programming' started by pinsrw, Jul 31, 2010.

  1. pinsrw macrumors regular

    May 30, 2010
    Hi all,

    I want to create an iPad app that responds to rotation, but shows a different arrangement of buttons/etc in each orientation.

    I figured out how to respond to the rotation itself, but how do I tell the view controller or window to change to the second view after rotation?

    Just trying to load the second Xib seems to cause a crash.

  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Have you looked into the cause of the crash? Read the crash log? Looked for runtime errors? Etc? And how are you "trying to load the second Xib"?
  3. Phantom1812 macrumors newbie

    Jul 20, 2010
    I think it all depends what you are doing and how much things 'change'. I assume you want to add extra controls, etc or have a whole lot of stuff change around.

    In which case, you could have everything ready and handle it manually by hiding/showing the controls when rotation is detected as well as repositioning using CGRectMake to position your elements.

    However, if you really do have vastly different views with extra functionality, you may well be better off creating both as UIViewControllers and adding each one to the main view controller, depending on the rotation.

    again, I'm fairly new to all this as well, so there may well be a slicker way, but i tend to use a combination of the above, depending on how much I actually change.

  4. pinsrw thread starter macrumors regular

    May 30, 2010
    #0 0x96598ef6 in __kill
    #1 0x96598ee8 in kill$UNIX2003
    #2 0x9662b62d in raise
    #3 0x966416e4 in abort
    #4 0x917a1fda in __gnu_cxx::__verbose_terminate_handler
    #5 0x0294c61c in _objc_terminate
    #6 0x917a017a in __cxxabiv1::__terminate
    #7 0x917a01ba in std::terminate
    #8 0x917a02b8 in __cxa_throw
    #9 0x0294c3d8 in objc_exception_throw
    #10 0x02833a5b in -[NSObject doesNotRecognizeSelector:]
    #11 0x027b0676 in ___forwarding___
    #12 0x027af9f2 in __forwarding_prep_0___
    #13 0x0000257e in -[iPadTestViewController receivedRotate:] at iPadTestViewController.m:27
    #14 0x0001a586 in _nsnote_callback
    #15 0x0279a165 in _CFXNotificationPostNotification
    #16 0x000112ca in -[NSNotificationCenter postNotificationName:eek:bject:userInfo:]
    #17 0x0048517c in -[UIDevice setOrientation:animated:]
    #18 0x002c5852 in -[UIApplication handleEvent:withNewEvent:]
    #19 0x002c04f7 in -[UIApplication sendEvent:]
    #20 0x002c81d8 in _UIApplicationHandleEvent
    #21 0x030c517c in PurpleEventCallback
    #22 0x0278189c in CFRunLoopRunSpecific
    #23 0x027808a8 in CFRunLoopRunInMode
    #24 0x030c389d in GSEventRunModal
    #25 0x030c3962 in GSEventRun
    #26 0x002c6372 in UIApplicationMain
    #27 0x0000229c in main at main.m:14

    I loaded the 2nd view in receivedRotate thus:
    UIView *view2 = [[UIView alloc] initWithNibName: @"Landscape" bundle:nil];
    [self.view addSubview: view2];
  5. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    UIView has no initWithNibName:bundle: instance method.

    Xcode probably flagged a warning about this when it compiled your code. Unless you have a good reason to justify ignoring a compile-time warning, don't.
  6. pinsrw thread starter macrumors regular

    May 30, 2010
    That worked for buttons and UITextView, but I've found that it doesn't work for UITableView.

    In fact, UITableView ends up looking like a mess. Either the lines are missing or the dimensions are wrong. It's just bad.

Share This Page