嗨那裏我現在有一行代碼的警告,我試圖將新視圖推送到屏幕上。 大綱//我的NSObject從我設置的服務器接收一個代碼= 1。一切工作正常的代碼來通過它然後初始化一個AlertView,我已經設置了一個if語句來捕獲按鈕點擊我的AlertView消息。當該按鈕被按下時,我的應用程序會崩潰。'NSObject'可能不會響應-navigationController
我已經聲明我的ViewController的視圖我試圖推動它的頭文件,沒有錯誤只是編譯時的警告。
這是我的NSObject的我已經
/////.h
#import <Foundation/Foundation.h>
@interface alerts : NSObject {
}
- (void)pleaseRegisterDevice;
@end
/////.m
#import "alerts.h"
#import "instaCode1_3AppDelegate.h"
#import "RegisterDeviceViewController.h"
@implementation alerts
//use this alert when phone falls out of sync
- (void)pleaseRegisterDevice {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please Register Device"
message:@"click OK to register"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert autorelease];
[alert show];
}
//Catch pleaseRegisterDevice method
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSString *buttonTitle=[alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"OK"]) {
NSLog(@"msg from alertView method");
//open new wndow
RegisterDeviceViewController *regViewController = [[RegisterDeviceViewController alloc] init];
//Push it onto the top pf the navigation controller's stack
**[[self navigationController] pushViewController:regViewController animated:YES];**
}
else {
NSLog(@"was not able to push view");
}
}
- (void)dealloc {
[super dealloc];
}
@end
我已經加粗的代碼行,我得到警告「提醒」可能不-navigationController
任何幫助應對將不勝感激。
謝謝你這個工作。我知道這個問題與此有關,但由於我明顯缺乏經驗,我不確定具體的細節。謝謝。 – tinhead 2011-04-26 04:52:20