当您将数据传输到服务器指示器活动时,我的应用程序在您服务器之后将数据发送到服务器。当指标隐藏时,我试图显示数据成功发送的警报。但是当我尝试撤消警报时,应用程序就会崩溃。可能是什么问题?谢谢!活动指示器和警报
- (void)viewDidLoad
{
[super viewDidLoad];
activityIndicator = [[UIActivityIndicatorView alloc] init];
activityIndicator.frame = CGRectMake(140, 190, 37, 37);
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[self.view addSubview:activityIndicator];
}
- (IBAction)sendForm:(id)sender {
[self performSelectorInBackground:@selector(loadData) withObject:activityIndicator];
[activityIndicator startAnimating];
}
-(void)loadData {
NSURL *scriptUrl = [NSURL URLWithString:@"http://zav333.ru/"];
NSData *data = [NSData dataWithContentsOfURL:scriptUrl];
if (data)
{
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://zav333.ru/sushi.php"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:15.0];
request.HTTPMethod = @"POST";
// указываем параметры POST запроса
NSString* params = [NSString stringWithFormat:@"name=%@&phone=%@&date=%@&howmuchperson=%@&smoke=%@ ", self.name.text, self.phone.text, self.date.text, self.howmuchperson.text, self.smoke];
*howMuchPerson, *smoke;
request.HTTPBody =[params dataUsingEncoding:NSUTF8StringEncoding];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[activityIndicator stopAnimating];
UIAlertView* ahtung = [[UIAlertView alloc] initWithTitle:@"Спасибо" message:@"Ваша заявка принята!\nВ течение часа, Вам поступит звонок для подтверждения заказа" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[ahtung show];
}
}
什么记录显示。 – Dilip 2013-02-16 10:39:13
crash log/stack trace plz – 2013-02-16 10:44:06
为什么不尝试在主线程中运行UIAlertView和[activityIndicator stopAnimating]。 – 2013-02-16 10:53:48