0

メインのビューコントローラーから別のビューコントローラーをロードするアプリを作成しました。ビューコントローラー1からビューコントローラー2への例...ビューコントローラー1ではボタンを押すとビューコントローラー2をロードする必要があります。ビューコントローラー2ではイカルセルビューも取得します。これが私のコードです

 -(IBAction)showcoll:(id)sender{

CollectionsViewController *sec=[[CollectionsViewController alloc]initWithNibName:Nil bundle:Nil];
sec.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;

NSLog(@"hi");
[self presentModalViewController:sec animated:YES];
}

 - (void)viewDidLoad
 {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGRect splashFrame =splash.frame;
splashFrame.origin.x = self.view.bounds.size.width;    

[UIView animateWithDuration:3
                      delay:1.0
                    options: UIViewAnimationCurveEaseOut
                 animations:^{
                     splash.frame = splashFrame;

                 } 
                 completion:^(BOOL finished){
                     NSLog(@"Done!");
                 }];
[self.view addSubview: splash];

 }

そして私が得た問題は

 2012-06-30 11:16:29.301 Minora[948:12203] Done!
 2012-06-30 11:16:31.195 Minora[948:12203] hi
 2012-06-30 11:16:31.198 Minora[948:12203] *** Terminating app due to uncaught exception      'NSUnknownKeyException', reason: '[<UIView 0x6e82b70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key dataSource.'
 *** Call stack at first throw:
 (
0   CoreFoundation                      0x013e45a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x02b97313 objc_exception_throw + 44
2   CoreFoundation                      0x013e44e1 -[NSException raise] + 17
3   Foundation                          0x00b3b677 _NSSetUsingKeyValueSetter + 135
4   Foundation                          0x00b3b5e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5   UIKit                               0x003eeff6 -[UIView(CALayerDelegate) setValue:forKey:] + 173
6   UIKit                               0x005b730c -[UIRuntimeOutletConnection connect] + 112
7   CoreFoundation                      0x0135a8cf -[NSArray makeObjectsPerformSelector:] + 239
8   UIKit                               0x005b5d23 -[UINib instantiateWithOwner:options:] + 1041
9   UIKit                               0x005b7ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
10  UIKit                               0x0046d628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
11  UIKit                               0x0046b134 -[UIViewController loadView] + 120
12  UIKit                               0x0046b00e -[UIViewController view] + 56
13  UIKit                               0x0046ca3d -[UIViewController viewControllerForRotation] + 63
14  UIKit                               0x00468988 -[UIViewController _visibleView] + 90
15  UIKit                               0x0070a93c -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 354
16  UIKit                               0x003e281e -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 954
17  UIKit                               0x0066a619 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 1381
18  UIKit                               0x0046f65d -[UIViewController presentModalViewController:withTransition:] + 3478
19  Minora                              0x0000317a -[ViewController showcoll:] + 218
20  UIKit                               0x003bb4fd -[UIApplication sendAction:to:from:forEvent:] + 119
21  UIKit                               0x0044b799 -[UIControl sendAction:to:forEvent:] + 67
22  UIKit                               0x0044dc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
23  UIKit                               0x0044c7d8 -[UIControl touchesEnded:withEvent:] + 458
24  UIKit                               0x003dfded -[UIWindow _sendTouchesForEvent:] + 567
25  UIKit                               0x003c0c37 -[UIApplication sendEvent:] + 447
26  UIKit                               0x003c5f2e _UIApplicationHandleEvent + 7576
27  GraphicsServices                    0x01539992 PurpleEventCallback + 1550
28  CoreFoundation                      0x013c5944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
29  CoreFoundation                      0x01325cf7 __CFRunLoopDoSource1 + 215
30  CoreFoundation                      0x01322f83 __CFRunLoopRun + 979
31  CoreFoundation                      0x01322840 CFRunLoopRunSpecific + 208
32  CoreFoundation                      0x01322761 CFRunLoopRunInMode + 97
33  GraphicsServices                    0x015381c4 GSEventRunModal + 217
34  GraphicsServices                    0x01538289 GSEventRun + 115
35  UIKit                               0x003c9c93 UIApplicationMain + 1160
36  Minora                              0x00002ada main + 170
37  Minora                              0x00002a25 start + 53
 )
 terminate called throwing an exception(lldb) 
4

2 に答える 2

1

この Sigabart は、modalViewController を提示すると発生しませんがUIView、実際にビューがまだ表示されていないため、viewDidLoad で何か間違ったことをしていると思います。dataSourceCollectionsViewController

于 2012-06-30T06:06:01.170 に答える
1

2 つの質問:

  1. 作成時に nib 名を指定していませんCollectionsViewControllernilニブ名に使うつもりだったの?

  2. ペン先を使用していない場合、splashビューが作成されている場所はわかりませんが、フレームのアニメーションに興味があり、そのフレームの変更をアニメーション化しますが、開始splashにサブビューとして追加しますアニメーション。それはすでにビューにありましたか(もしそうなら、なぜ再び追加するのですか)?そうでない場合は、(a) どこで作成しているか、(b) アニメーションの前にサブビューとして追加していないのはなぜですか?

于 2012-06-30T06:12:49.590 に答える