0
我的加载应用程序检查用户是否在文件系统中有一个文件,如果没有,它会弹出一个使用presentModalViewController的视图控制器,并且在用户使用该视图登录后控制器我的应用程序应该从网上获取一些数据。PresentModalViewController不会停止工作流程
我的问题是,在presentModalViewController之后,视图控制器会弹出,但presentModalViewController之后的代码继续运行而不等待VC返回。
我的代码:
- (void)viewDidLoad
{
[self getPasswordFromFile];
responseData = [[NSMutableData data] retain];
NSString *URL= [NSString stringWithFormat:@"http://localhost/domything/get_status.php?ownerid=%@", nOwnerID];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:URL]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
[super viewDidLoad];
}
-(void)getPasswordFromFile
{
NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [arrayPaths objectAtIndex:0];
NSString *filePath = [docDirectory stringByAppendingString:@"/pwfile"];
NSError *error;
NSString *fileContents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error];
if(fileContents==nil)
{
// Show registration screen
LoginScreenVC *vcLoginScreen = [[[LoginScreenVC alloc] init] autorelease];
[vcLoginScreen setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:vcLoginScreen animated:YES];
}
NSArray *arr = [fileContents componentsSeparatedByString:@":"];
// NSLog(@"ownerid is:%@, password is: %@", [arr objectAtIndex:0], [arr objectAtIndex:1]);
password = [arr objectAtIndex:1];
nOwnerID = [arr objectAtIndex:0];
[password retain];
[nOwnerID retain];
}
真的吗?我认为模态的全部想法是在视图完成之前停止一切。这让我难过。 –
这不是它的工作原理。主运行循环处理所有触摸事件并绘制屏幕。如果它在呈现之后停止,则不会再进行触摸事件或屏幕绘制,因此您甚至不会看到模式视图控制器出现或能够与其进行交互。 – mattjgalloway
谢谢,我现在正在用文档破解我的头脑。 –