iphone - 如何正确显示 UIViewController?

标签 iphone objective-c ios xcode uiviewcontroller

我需要显示一个 View Controller 并拥有这个当前代码:

    SavedFiles *savedFilesVC = [[[SavedFiles alloc] init] autorelease];
    [self presentModalViewController:savedFilesVC animated:YES];   

虽然它得到这个错误:
2011-09-12 18:38:45.808 iDHSB[248:707] -[iDHSB_MobileAppDelegate presentModalViewController:animated:]: unrecognized selector     
sent to instance 0x1bb880
2011-09-12 18:38:45.825 iDHSB[248:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-   
[iDHSB_MobileAppDelegate presentModalViewController:animated:]: unrecognized selector sent to instance 0x1bb880'
*** Call stack at first throw:
(
0   CoreFoundation                      0x3583064f __exceptionPreprocess + 114
1   libobjc.A.dylib                     0x36583c5d objc_exception_throw + 24
2   CoreFoundation                      0x358341bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3   CoreFoundation                      0x35833649 ___forwarding___ + 508
4   CoreFoundation                      0x357aa180 _CF_forwarding_prep_0 + 48
5   iDHSB                               0x00007671 -[iDHSB_MobileAppDelegate actionSheet:clickedButtonAtIndex:] + 140
6   UIKit                               0x3203c03d -[UIActionSheet(Private) _buttonClicked:] + 192
7   CoreFoundation                      0x357a0571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
8   UIKit                               0x31f39ec9 -[UIApplication sendAction:to:from:forEvent:] + 84
9   UIKit                               0x31f39e69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
10  UIKit                               0x31f39e3b -[UIControl sendAction:to:forEvent:] + 38
11  UIKit                               0x31f39b8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
12  UIKit                               0x31f3a423 -[UIControl touchesEnded:withEvent:] + 342
13  UIKit                               0x31f38bf5 -[UIWindow _sendTouchesForEvent:] + 368
14  UIKit                               0x31f3856f -[UIWindow sendEvent:] + 262
15  UIKit                               0x31f21313 -[UIApplication sendEvent:] + 298
16  UIKit                               0x31f20c53 _UIApplicationHandleEvent + 5090
17  GraphicsServices                    0x31df7e77 PurpleEventCallback + 666
18  CoreFoundation                      0x35807a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
19  CoreFoundation                      0x3580983f __CFRunLoopDoSource1 + 166
20  CoreFoundation                      0x3580a60d __CFRunLoopRun + 520
21  CoreFoundation                      0x3579aec3 CFRunLoopRunSpecific + 230
22  CoreFoundation                      0x3579adcb CFRunLoopRunInMode + 58
23  GraphicsServices                    0x31df741f GSEventRunModal + 114
24  GraphicsServices                    0x31df74cb GSEventRun + 62
25  UIKit                               0x31f4bd69 -[UIApplication _run] + 404
26  UIKit                               0x31f49807 UIApplicationMain + 670
27  iDHSB                               0x0000232d main + 48
28  iDHSB                               0x000022f8 start + 40
)
terminate called after throwing an instance of 'NSException'
[Switching to process 11779 thread 0x0]

为什么会这样?

我需要做什么?

谢谢,

詹姆士

最佳答案

试试这个

[self.navigationController pushViewController:viewController animated:YES];

或者
[self.view addsubview.viewcontroller.view];

关于iphone - 如何正确显示 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7391738/

相关文章:

javascript - 哪个事件将以最快和最一致的方式触发 - matchMedia、window.resize、orientationchange 或两者?

iphone - UIScroll : enable touch event even when it is scrolling

java - Objective-c 和 java 的区别

ios - 我可以将 rootViewController 更改为 ViewController 内的不同 Storyboard View 吗?

ios - 当我禁用/启用按钮时, View 如何自行重绘?

iPhone - 确定 ImageView 显示的图像

iphone - 如何设置 NSPredicate 来检查关系的属性?

Objective-C NSString 引用类型

iphone - iPad 使用图像和 javascript 将本地 HTML 加载到 Web View 中

ios - 接入互联网时 SCNetworkReachabilityFlags 为 0