첫 번째 Viewcontroller의 IBOutlet에 AppDelegate 클래스로 액세스하려고합니다. 내 프로젝트는 스토리 보드을 기반으로하며 첫 번째 Viewcontroller에 대한 참조가 없습니다. 어떻게해야할까요? 이 IBOutlet을 첫 번째 Viewcontroller의 속성으로 설정해야하지만 AppDelegate에서 설정해야한다는 것을 알고 있습니다. 어떻게 접근 할 수 있습니까? 감사iOS : AppDelegate의 firstviewcontroller 액세스
0
A
답변
0
당신은 당신의 rootViewController
앱의 대리자에 액세스 할 수 있습니다
self.window.rootViewController
예 :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MyVCClass *firstVC = (MyVCClass*)self.window.rootViewController;
[firstVC someMethod];
}
조심, 당신의 ViewController가 시작/아직로드되지 않았을 수 있습니다.
0
앱의 UIWindow에 rootViewController를 설정하지 않았으므로
[[UIApplication sharedApplication].keyWindow rootViewController]
을 사용하면 nil이 표시됩니다.
당신이 rootViewController 같은 AppDelegate.m에서의 ViewController를 가져
UIViewController *vc = [self.navigationController.viewControllers objectAtIndex:0];
0
먼저 얻기 위해 단순히 당신이 할 수있는 다음 탐색을위한 스토리 보드를 사용하는 경우 : 다음
#import "YourViewController"
AppDelegate에에에게 .m 아래 코드를 넣으십시오.
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
YourViewController * view = [[YourViewController alloc]init];
self.window.rootViewController = view;
}
관련 문제
- 1. iOS - AppDelegate의 내비게이션 컨트롤러
- 2. Android의 iOS Appdelegate의 대안은 무엇입니까
- 3. Xcode/iOS - AppDelegate의 ViewController에 대한 참조
- 4. 는 FirstViewController 클래스에 FirstViewController에서
- 5. 변화 firstviewcontroller 버튼 표제
- 6. AppDelegate의 UISegmentedControl
- 7. AppDelegate의 PresentViewController
- 8. 시작시 SecondViewController를 엽니 다. FirstViewController
- 9. AppDelegate의 NSURLConnection 및 SBJSon
- 10. iOS : 피커 뷰에서 MFMailComposeViewController를 사용하여 AppDelegate의 자동 풀 풀
- 11. AppDelegate의 다중 NSManagedObjectContext
- 12. AppDelegate의 UIActionSheet를 닫습니다.
- 13. AppDelegate의 openURL 이후 Segue
- 14. Appdelegate의 컨트롤러가 공개되지 않습니다.
- 15. AppDelegate의 자체 메서드
- 16. AppDelegate의 SQLite가 필요합니까?
- 17. appDelegate의 CoreData 문제
- 18. AppDelegate의 XMPP Framework 코드
- 19. AppDelegate의 iphone setRightBarButtonItem
- 20. Swift로 AppDelegate의 UINavigationBar setBackgroundImage
- 21. AppDelegate의 창 닫기에 응답합니다.
- 22. SplitView의 DetailViewController에서 AppDelegate의 탐색 컨트롤러에 액세스 할 수 있도록 설정합니다.
- 23. iOS : geojson iOS 액세스
- 24. 클래스 <code>FirstViewController</code>에서 NSUserDefaults
- 25. AppDelegate의 NSNumber가 올바르게 비교되지 않습니다.
- 26. appDelegate의 locationManager에서 viewController로 좌표를 전달하십시오.
- 27. AppDelegate의 TabBarController에서 ViewController를 얻으려면 어떻게해야합니까?
- 28. 아이폰에서 AppDelegate의 Bonjour 서비스를 찾았습니다.
- 29. 링크가있는 AppDelegate의 ViewController를 엽니 다.
- 30. Swift : AppDelegate의 레이블 텍스트 설정
왜 그렇게해야합니까? 어쩌면 앱 아키텍처/디자인이 좋지 않을 수도 있습니다. – Larme
이 viewController를 어딘가에 앱 창의 rootViewController로 설정합니까? –