来自 AppDelegate 的警告
当我调用其他视图控制器时,我收到以下警告。
WindowMultivewAppDelegate 可能不会响应 -switchView 来查看
这是我在 Firstviewcontroller.m 中的代码
- (IBAction)swapViews:(id)sender{
WindowMultiViewAppDelegate *delegate = (WindowMultiViewAppDelegate *)[[UIApplication sharedApplication] delegate];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[delegate switchView:self toView:secondView.view];
}
这是我在 Firstviewcontroller.h 中的代码
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController {
}
- (IBAction)swapViews:(id)sender;
@end
appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
initWithNibName:@"FirstViewController" bundle:nil];
[self.window addSubview:navigationController.view];
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
if ([CLLocationManager locationServicesEnabled]) {
[locationManager startUpdatingLocation];
}
[self.window makeKeyAndVisible];
return YES;
}
中的 appdelegate.h
@interface WindowMultiViewAppDelegate : NSObject <UIApplicationDelegate, CLLocationManagerDelegate , MKMapViewDelegate> {
UIWindow *window;
UINavigationController *navigationController;
CLLocationManager *locationManager;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet CLLocationManager *locationManager;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@end
我已将 UInavgationcontroller 放入 mainWindow.xib 中,这会导致我命名为 FirstViewController 的根视图控制器
当按下下一个按钮时,应用程序会在第二个视图控制器中停止,该按钮内部有该操作
- (IBAction)swapNext:(id)sender
{
WindowMultiViewAppDelegate *delegate = (WindowMultiViewAppDelegate *)[[UIApplication sharedApplication] delegate];
MediaViewController *mediaView = [[MediaViewController alloc] initWithNibName:@"MediaViewController" bundle:nil];
[delegate switchView:self toView:mediaView.view];
}
我做错了什么?
谁能告诉我如何将更多子视图连接到 UINavigationController 中 我希望其中一个子视图成为视频播放器 - 离线 - 另一个子视图成为查找用户位置的地图
我是初学者....当我知道我将帮助其他人时,谢谢大家: ))
I am getting the following warning when I am calling other view controllers..
WindowMultivewAppDelegate might not respond to -switchView to view
This is my code in the Firstviewcontroller.m
- (IBAction)swapViews:(id)sender{
WindowMultiViewAppDelegate *delegate = (WindowMultiViewAppDelegate *)[[UIApplication sharedApplication] delegate];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[delegate switchView:self toView:secondView.view];
}
this is my code in the Firstviewcontroller.h
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController {
}
- (IBAction)swapViews:(id)sender;
@end
in the appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
initWithNibName:@"FirstViewController" bundle:nil];
[self.window addSubview:navigationController.view];
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
if ([CLLocationManager locationServicesEnabled]) {
[locationManager startUpdatingLocation];
}
[self.window makeKeyAndVisible];
return YES;
}
in the appdelegate.h
@interface WindowMultiViewAppDelegate : NSObject <UIApplicationDelegate, CLLocationManagerDelegate , MKMapViewDelegate> {
UIWindow *window;
UINavigationController *navigationController;
CLLocationManager *locationManager;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet CLLocationManager *locationManager;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@end
I have placed a UInavgationcontroller into the mainWindow.xib which leads to the rootviewcontroller which i named FirstViewController
The application quites in the secondviewcontroller when a button next is pressed which has that action inside
- (IBAction)swapNext:(id)sender
{
WindowMultiViewAppDelegate *delegate = (WindowMultiViewAppDelegate *)[[UIApplication sharedApplication] delegate];
MediaViewController *mediaView = [[MediaViewController alloc] initWithNibName:@"MediaViewController" bundle:nil];
[delegate switchView:self toView:mediaView.view];
}
What am I doing wrong??
Can anybody tell me how to connect more subviews into the UINavigationController
I want one of this subviews to be a video player - offline- and the other one to be a map which find the user"s location
I am a beginner.... thank you all when I learn I am going to help others :))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有看到您在任何地方定义了
switchView:
方法,因此您收到有关此问题的警告也就不足为奇了。I don't see that you define the
switchView:
method anywhere, so it's no surprise that you get a warning about this.