나는 해결할 수없는 며칠 동안 큰 문제가있다. MMMainViewController에서로드내 견해가 얼어 버린 이유를 모르겠다.
@implementation MMMainViewController
@synthesize login, password, connectPass, navigationController, accountVC;
- (void)viewDidLoad {
// Set a title for each view controller. These will also be names of each tab
accountVC.title = @"Account";
accountVC.tabBarItem.image = [UIImage imageNamed:@"icon_user.png"];
self.view.frame = CGRectMake(0, 0, 320, 480);
// Set each tab to show an appropriate view controller
[self setViewControllers:
[NSArray arrayWithObjects:accountVC, nil]];
[navigationController setNavigationBarHidden:NO animated:NO];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Menu"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
[self setTitle:@"Menu"];
}
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithLogin:(NSString *)l password:(NSString *)p connectPass:(NSString *)c navigationController:(UINavigationController *)navController nibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
self.view = contentView;
[contentView release];
login = l;
password = p;
connectPass = c;
navigationController = navController;
if (!accountVC)
accountVC = [MMAccountViewController alloc];
[self.accountVC
initWithNibName:@"MMAccountViewController" bundle:nil];
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
return self;
}
- (void)dealloc {
[connectPass release];
[login release];
[password release];
[super dealloc];
}
레이어 MMAccountViewController은 아무것도 기본 뷰 컨트롤러 : MMMainViewController이 코드에있어, 후
@implementation MMConnectionViewController
@synthesize login, password, activityIndicator, mainVC;
- (BOOL)textFieldShouldReturn:(UITextField *)aTextField
{
[aTextField resignFirstResponder];
[self performSelectorOnMainThread:@selector(startRolling) withObject:nil waitUntilDone:NO];
[NSThread detachNewThreadSelector:@selector(connect) toTarget:self withObject:nil];
return YES;
}
- (void)viewWillAppear:(BOOL)flag {
[super viewWillAppear:flag];
[login becomeFirstResponder];
login.keyboardAppearance = UIKeyboardAppearanceAlert;
password.keyboardAppearance = UIKeyboardAppearanceAlert;
[self setTitle:@"Monaco Marine"];
UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
self.navigationItem.backBarButtonItem = backBarButtonItem;
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
[backBarButtonItem release];
}
- (void)connect {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
mainVC = [[MMMainViewController alloc] initWithLogin:login.text password:password.text connectPass:@"1" navigationController:self.navigationController nibName:@"MMMainViewController" bundle:nil];
if (mainVC) {
[self performSelectorOnMainThread:@selector(dataLoadingFinished) withObject:nil waitUntilDone:YES];
}
[pool release];
}
- (void)dataLoadingFinished {
self.stopRolling;
[self.navigationController pushViewController:mainVC animated:YES];
}
- (void)showAlertWithMessage:(NSString *)message {
self.stopRolling;
NSLog(@"%@",message);
UIAlertView *warning = [[UIAlertView alloc] initWithTitle:@"Connection Failed" message:[NSString stringWithFormat:@"%@",message] delegate:self cancelButtonTitle:@"Retry" otherButtonTitles:nil];
[warning show];
[warning release];
}
- (void)startRolling {
[activityIndicator startAnimating];
}
- (void)stopRolling {
[activityIndicator stopAnimating];
}
- (void)viewDidLoad {
[login becomeFirstResponder];
}
- (void)dealloc {
[login release],login=nil;
[password release],password=nil;
[activityIndicator release],activityIndicator=nil;
[super dealloc];
}
:
우선 나는이 코드를 사용하여 로그인 뷰 컨트롤러가 그 안에.
이제 문제는 내 탭보기 컨트롤러를로드하고 나는 로그인 뷰 컨트롤러로 돌아가 때때로 때, 메시지와 함께 화면 정지 및 버그 (NSZombieEnabled = YES) :
*** -[CALayer retain]: message sent to deallocated instance 0xd0199d0
이를 내가 가진 전부이고, 내가 틀린 곳을 정말로 볼 수는 없습니다.
더 많은 아이디어가 있습니까?
나를 도와 줘서 고마워!
답장을 보내 주셔서 감사합니다. 나는 이것을 시도 할 것이다. 어쩌면 문제는 viewcontroller가 생성 될 때부터옵니다. 내 mainViewController.m에 많은 코드가 없습니다. 첫 번째 viewController로 내 메시지를 편집하려고합니다. –
내 생각 엔이 일은해서는 안되는 뷰 컨트롤러를 공개하는 것과 직접 관련이 있습니다. 옆으로, 애플 이름과 같은 객체 이름을 사용하지 않는 것이 가장 좋다. 예를 들면 다음과 같다.'self.navigationItem.backBarButtonItem = backBarButtonItem; ' – iwasrobbed
Ok이 작은 프로그램을 만들려고 노력할 것이다. 문제는 버그가 무작위로 올 수 있다는 것입니다. 때로는 첫 번째 푸시 이후에 나오지만 때로는 나중에 표시되지만 항상 같은보기로 표시됩니다. 시뮬레이터 또는 다른 외부 매개 변수로 인해 내 프로그램의 동작이 변경 될 수 있습니까? @IWasRobbed 당신이 맞습니다. 내 물건의 이름을 주목하지 않았습니다. 나는 이것에 대한 점검을 할 것이다. 내가 확실하지 않은 것 : 뷰 컨트롤러가 클래스의 속성 (다음 뷰 컨트롤러 참조)으로있을 때 dealloc 메서드에서 해제해야합니까 아니면 다른 곳에서 관리해야합니까? –