1
我收到錯誤'MillersAppAppDelegate'可能不會響應'委託'。我仍然在學習所有這些,但不完全理解,因爲我已經讀過,這通常發生在未在頭文件中聲明方法時。我使用的XCode 4.這裏是代碼的我期待在部分:AppDelegate可能不會響應'委託'
#import <UIKit/UIKit.h>
@interface MainViewController : UIViewController {
}
-(IBAction) contactButtonClick:(id)sender;
@end
而這裏的.m文件:
#import "MainViewController.h"
#import "MillersAppAppDelegate.h"
#import "ContactViewController.h"
@implementation MainViewController
-(IBAction) contactButtonClick:(id)sender{
MillersAppAppDelegate *delegate = [(MillersAppAppDelegate *)[UIApplication sharedApplication] delegate]; <---this line gets the warning "'MillersAppAppDelegate' may not respond to 'delegate'"
ContactViewController *contactView = [[ContactViewController alloc]initWithNibName:@"ContactViewController" bundle:nil];
[delegate switchViews:self.view toView:contactView.view];
}
程序運行正常,但我有幾個其他動作會產生相同的警告(全部涉及視圖切換)。感謝您的幫助,我確信這是一個簡單的答案,但我仍然是初學者。這也可能是XCode3和XCode 4之間的問題?
嘿!如果我的回答有幫助,請接受它。否則,請向我們提供更多信息。 – Phlibbo
非常感謝!這樣一個簡單的解決方法,我的大腦被所有人炒得沸沸揚揚,我仍然感到困惑,我仍然處於學習階段。我很感激! – MillerMedia
完全沒問題,歡迎來到:) – Phlibbo