mluton / EmbeddedSwapping

Demonstration of how to make a custom container view controller manage multiple child view controllers using storyboards.
MIT License
208 stars 30 forks source link

Can't make it work on iPad #2

Closed rtamesis closed 11 years ago

rtamesis commented 11 years ago

I basically tried implementing the code that you so graciously posted for the iPad instead, and I keep getting this error when I run it:

2013-05-27 17:55:22.509 CustomContainers[20795:c07] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7543fe0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key swapViewControllers.' * First throw call stack: (0x1c93012 0x10d0e7e 0x1d1bfb1 0xb7ce41 0xafe5f8 0xafe0e7 0xb28b58 0x232019 0x10e4663 0x1c8e45a 0x230b1c 0xf57e7 0xf5dc8 0xf5ff8 0xf6232 0x453d5 0x4576f 0x45905 0x4e917 0x1296c 0x1394b 0x24cb5 0x25beb 0x17698 0x1beedf9 0x1beead0 0x1c08bf5 0x1c08962 0x1c39bb6 0x1c38f44 0x1c38e1b 0x1317a 0x14ffc 0x1eed 0x1e15) libc++abi.dylib: terminate called throwing an exception

Any suggestions or help on getting it to work would be very much appreciated. Thanks!

Richard

rtamesis commented 11 years ago

I tried creating a new project and basically imported your original files into it after thinking that I may have made an error somewhere typing it in. After wiring the different scenes up in the storyboard and setting up the classes of the different scenes, it worked! So I guess I must have screwed something up previously. However, when I keep switching between the first and second view controllers, it eventually crashes with this error message:

2013-05-27 18:30:27.902 CustomContainers2[21252:c07] FirstViewController - viewDidLoad 2013-05-27 18:30:30.763 CustomContainers2[21252:c07] SecondViewController - viewDidLoad 2013-05-27 18:30:44.602 CustomContainers2[21252:c07] Unbalanced calls to begin/end appearance transitions for <SecondViewController: 0x8a46b00>. 2013-05-27 18:30:45.395 CustomContainers2[21252:c07] Unbalanced calls to begin/end appearance transitions for <SecondViewController: 0x8a46b00>. 2013-05-27 18:30:52.987 CustomContainers2[21252:c07] Unbalanced calls to begin/end appearance transitions for <FirstViewController: 0x758dc30>. 2013-05-27 18:30:55.593 CustomContainers2[21252:c07] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array' *\ First throw call stack: (0x1c94012 0x10d1e7e 0x1c49b44 0x2862 0x45db87 0xf7dd2 0x3124 0x3884 0x10e5705 0x192c0 0x19258 0xda021 0xda57f 0xd96e8 0x48cef 0x48f02 0x26d4a 0x18698 0x1befdf9 0x1befad0 0x1c09bf5 0x1c09962 0x1c3abb6 0x1c39f44 0x1c39e1b 0x1bee7e3 0x1bee668 0x15ffc 0x1bdd 0x1b05) libc++abi.dylib: terminate called throwing an exception (lldb)

mluton commented 11 years ago

Ah, thanks for the note. Apparently, it's possible to rapidly tap the Swap button which will trigger a view controller swap (along with with its animation) before the previous swap has completed. I added in a guard against this happening. You can now happily tap the Swap button as fast as you want. The tap will be ignored if a transition is currently in progress.

mluton commented 11 years ago

Also, whenever I've been bitten by the 'class is not key value coding-compliant for...' it is usually because an outlet isn't wired up in a nib/storyboard.

rtamesis commented 11 years ago

Thanks for the quick response. This has been highly useful and instructive! Any suggestions on how to implement transitions between the viewcontrollers other than the flip and dissolve that Apple already gives us?

mluton commented 11 years ago

Unfortunately, I don't have much experience with custom animations for the transition. However, this StackOverflow answer might be a good place to start researching.

http://stackoverflow.com/questions/12009154/custom-animation-between-uiviewcontrollers-using-transitionfromviewcontrollerto