Можете ли вы опубликовать часть своего кода? Трудно спекулировать, не видя, что происходит, но я все равно попробую.
Вам нужно переместить код, к которому вы подключаетесь к серверу, из viewDidLoad и поместить его в метод обратного вызова или что-то в этом роде. Я бы предложил выдать предупреждение с полем имени и пароля, сделать контроллер представления делегатом предупреждения, а затем подключить функцию clickedButtonAtIndex к серверу.
Пример:
-(void)viewDidLoad {
UIAlertView *loginAlert = [[UIAlertView alloc] initWithTitle:@"Login" message:@"Please enter your username and password below" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Login",nil];
//You might have to do some fiddling with the frame sizes to make it fit in the alert.
UITextField *userNameField = [[UITextField alloc] initWithFrame:CGRectMake(originX, originY, lengthX, lengthY)];
userNameField.placeholder = @"User Name";
[loginAlert addSubview:userNameField];
//loginAlert will retain this so we release it now.
[userNameField release];
[UITextField *passwordNameField = [[UITextField alloc] initWithFrame:CGRectMake(originX, originY, lengthX, lengthY)];
passwordNameField.secureTextEntry = YES;
[loginAlert addSubview:passwordNameField];
[passwordNameField release]
//This line tells the iPhone to stretch out your AlertView so it's big enough for your two textViews, we use 0 and 130 respectively but we only have one text field.
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(stretchX, stretchY);
[loginAlert setTransform:myTransform];
[loginAlert show];
[loginAlert release];
}
//Implement this method, it will be called when the user clicks the "login" button on your alert.
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
//Usually if they click cancel you do nothing, thats buttonIndex 0
if(buttonIndex == 1) {
//Connect to the server with the correct login and password.
}
}