【问题标题】:Warning from AppDelegate来自 AppDelegate 的警告
【发布时间】:2011-08-07 18:07:15
【问题描述】:

我在调用其他视图控制器时收到以下警告..

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

我在 mainWindow.xib 中放置了一个 UInavgationcontroller,它通向我命名为 FirstViewController 的 rootviewcontroller

当按下下一个按钮时,应用程序在 secondviewcontroller 中停止,其中包含该操作

- (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 我希望其中一个子视图成为视频播放器 - 离线 - 而另一个是找到用户位置的地图

我是初学者....谢谢大家当我知道我会帮助别人:))

【问题讨论】:

  • 欢迎来到 Stack Overflow! tinyurl.com/sohints 有很好的介绍如何编写易于回答的问题。首先,使用您正在使用的目标平台和编程语言标记您的问题。

标签: iphone objective-c video geolocation subviews


【解决方案1】:

我没有看到您在任何地方定义了 switchView: 方法,因此您收到关于此的警告也就不足为奇了。

【讨论】:

  • - (void)switchView:(UIView *)View1 toView:(UIView *)View2 { [UIView beginAnimations:@"" context:nil]; [UIView setAnimationCurve:0.75]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.window cache:YES]; [窗口添加子视图:View2]; [UIView 提交动画]; } // switchview 在 windowMultiViewAppDelegate.m ISN"T THAT RIGHT ?? 我认为问题在于下一个视图是用于播放视频文件.. 你知道我应该怎么做吗??跨度>
  • 您为什么不将此添加到您的问题中?您粘贴了一大堆不相关的代码,使其难以阅读,但却遗漏了您的警告所指的单个方法......您可能忘记在头文件中声明该方法,因此编译器警告。
  • 顺便说一句,animationCurve 参数必须是UIViewAnimationCurve(即enum),而不是float,请使用UIViewAnimationCurveEaseInEaseOut之类的东西。
  • 我很抱歉我刚进入这个论坛,我也有点恐慌,但谢谢你的建议 :))
猜你喜欢
  • 1970-01-01
  • 2019-05-09
  • 2018-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-22
  • 1970-01-01
  • 2011-05-18
相关资源
最近更新 更多