1
你好我正在使用分析來幫助我的iOS應用程序的後端,並且我創建了一個按鈕,可以將我的文本保存在我的文本字段中,並將其上傳到雲中點擊一個按鈕。當上傳數據到Parse.com時,UIAlertView似乎凍結應用程序
的按鈕,並在彈出的警告的代碼如下
- (IBAction)savebutton:(id)sender {
// Create PFObject with recipe information
PFObject *recipe = [PFObject objectWithClassName:@"GolfTimes"];
[recipe setObject:_nameTextField.text forKey:@"Name"];
[recipe setObject:_prepTimeTextField.text forKey:@"MemberNumber"];
[recipe setObject:_NumberOfGolfers.text forKey:@"NumberOfGolfers"];
[recipe setObject:_RequestedTime.text forKey:@"RequestedTime"];
NSArray *ingredients = [_ingredientsTextField.text componentsSeparatedByString: @","];
[recipe setObject:ingredients forKey:@"Telephone"];
// Show progress
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Sending...";
[hud show:YES];
// Upload recipe to Parse
[recipe saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
[hud hide:NO];
if (!error) {
// Show success message
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Request Sent" message:@"We will get back to you with confirmation." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
// Notify table view to reload the recipes from Parse cloud
[[NSNotificationCenter defaultCenter] postNotificationName:@"refreshTable" object:self];
// Dismiss the controller
[self dismissViewControllerAnimated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Upload Failure" message:[error localizedDescription] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}];}
雖然數據併發送正確的和我把它做的視圖控制器不關閉,警報似乎凍結應用我大部分時間都無法點擊「確定」。當我點擊「確定」按鈕時,應用模擬器關閉。
任何建議或幫助?
是的,改變委託爲零修復問題。非常感謝@ troop231 –