Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 31, 2010, 07:30 PM   #1
pinsrw
Banned
 
Join Date: May 2010
Newbie question iPad views

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.

Thanks-

Last edited by pinsrw; Aug 1, 2010 at 06:54 AM.
pinsrw is offline   0 Reply With Quote
Old Aug 1, 2010, 11:09 AM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by pinsrw View Post
Just trying to load the second Xib seems to cause a crash.
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"?
__________________
dejo is offline   0 Reply With Quote
Old Aug 1, 2010, 11:32 AM   #3
Phantom1812
macrumors newbie
 
Join Date: Jul 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.

P~
Phantom1812 is offline   0 Reply With Quote
Old Aug 1, 2010, 08:28 PM   #4
pinsrw
Thread Starter
Banned
 
Join Date: May 2010
Quote:
Originally Posted by dejo View Post
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"?
#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 postNotificationNamebject: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:
Code:
UIView *view2 = [[UIView alloc] initWithNibName: @"Landscape" bundle:nil];
[self.view addSubview: view2];
pinsrw is offline   0 Reply With Quote
Old Aug 2, 2010, 10:42 AM   #5
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by pinsrw View Post
...
#10 0x02833a5b in -[NSObject doesNotRecognizeSelector:]
...

I loaded the 2nd view in receivedRotate thus:
Code:
UIView *view2 = [[UIView alloc] initWithNibName: @"Landscape" bundle:nil];
[self.view addSubview: view2];
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.
__________________

Last edited by dejo; Aug 2, 2010 at 10:50 AM.
dejo is offline   0 Reply With Quote
Old Aug 4, 2010, 02:47 PM   #6
pinsrw
Thread Starter
Banned
 
Join Date: May 2010
Quote:
Originally Posted by Phantom1812 View Post
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.
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.

Last edited by pinsrw; Aug 5, 2010 at 11:14 AM.
pinsrw is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
ipad mini users views on Nexus 7 (2013) hbksabhi Alternatives to iOS and iOS Devices 27 Sep 9, 2013 03:24 AM
iTunes 11 Views Question xSinghx Mac Applications and Mac App Store 0 Nov 29, 2012 02:35 PM
Newbie question re iPad 2 and old iPod touch? horvie iPad 0 Sep 24, 2012 09:28 AM

Forum Jump

All times are GMT -5. The time now is 07:25 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC