단추를 눌렀을 때 활동 표시기를 시작하려하지만 아무 것도 일어나지 않습니다. 버튼과 활동은 모두 IBOutlets입니다. 데이터가 수신되면 다음 뷰 컨트롤러를 푸시하기 때문에 버튼이 작동하는 것을 알고 있습니다.UIButton이 숨기지 않고 활동 표시기가 시작되지 않음
여기에 모든 코드입니다 :
@interface MembershipInfoViewController()
@end
@implementation MembershipInfoViewController {
Menu *menuClass;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
menuClass = [[Menu alloc]init];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"Enter Membership Info";
[self.loadingIndicator stopAnimating];
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
UIImage *hamburgerButton = [UIImage imageNamed:@"list_button"];
UIBarButtonItem *listButton = [[UIBarButtonItem alloc]initWithImage:hamburgerButton style:UIBarButtonItemStylePlain target:self action:@selector(showMenuList)];
self.navigationItem.leftBarButtonItem = listButton;
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(showMenuList)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRecognizer];
}
UIColor *kfbBlue = [UIColor colorWithRed:8.0/255.0f green:77.0/255.0f blue:139.0/255.0f alpha:1];
self.firstName.textColor = kfbBlue;
self.firstName.autocorrectionType = UITextAutocorrectionTypeNo;
self.firstName.keyboardType = UIKeyboardTypeDefault;
self.firstName.returnKeyType = UIReturnKeyDefault;
self.firstName.clearButtonMode = UITextFieldViewModeWhileEditing;
self.firstName.clearsOnBeginEditing = TRUE;
self.firstName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
self.lastName.textColor = kfbBlue;
self.lastName.autocorrectionType = UITextAutocorrectionTypeNo;
self.lastName.keyboardType = UIKeyboardTypeDefault;
self.lastName.returnKeyType = UIReturnKeyDefault;
self.lastName.clearButtonMode = UITextFieldViewModeWhileEditing;
self.lastName.clearsOnBeginEditing = TRUE;
self.lastName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
self.membershipNumber.textColor = kfbBlue;
self.membershipNumber.autocorrectionType = UITextAutocorrectionTypeNo;
self.membershipNumber.keyboardType = UIKeyboardTypeDefault;
self.membershipNumber.returnKeyType = UIReturnKeyDefault;
self.membershipNumber.clearButtonMode = UITextFieldViewModeWhileEditing;
self.membershipNumber.clearsOnBeginEditing = TRUE;
self.membershipNumber.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
self.checkInfoButton.layer.borderColor = [UIColor whiteColor].CGColor;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)checkInfo {
if ([self.firstName.text isEqual:@""]||[self.lastName.text isEqual:@""]||[self.membershipNumber.text isEqual:@""]) {
UIAlertView *emptyFieldAlert = [[UIAlertView alloc]initWithTitle:@"All Fields Are Required!" message:@"Please fill out all fields." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[emptyFieldAlert show];
}
else if (self.membershipNumberString.length < 10||self.membershipNumberString.length > 10) {
UIAlertView *numberAlert = [[UIAlertView alloc]initWithTitle:@"Membership Number Must Be 10 Characters!" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[numberAlert show];
}
else {
[self.checkInfoButton setHidden:YES];
[self.loadingIndicator startAnimating];
NSString *urlString = @"http://127.0.0.1:8888/PhpProject1/DBTest.php?first_name=%@&last_name=%@&membership_number=%@";
NSString *stringURL = [NSString stringWithFormat:urlString, _firstNameString, _lastNameString, _membershipNumberString];
self.url = [NSURL URLWithString:stringURL];
dispatch_async(kBgQueue, ^{
NSData *data = [NSData dataWithContentsOfURL:self.url];
if (data == nil)
{
NSLog(@"data is nil");
}
else
{
[self performSelectorOnMainThread:@selector(fetchData:) withObject:data waitUntilDone:YES];
}
if ([self.responseStatus isEqual:@"A"]) {
MembershipCardViewController *cardView = [[MembershipCardViewController alloc]initWithNibName:nil bundle:nil];
NSString *fullName = [[self.responseFirstName stringByAppendingString:@" "]stringByAppendingString:self.responseLastName];
cardView.nameString = fullName;
[self.navigationController pushViewController:cardView animated:YES];
}
else {
UIAlertView *notActiveAlert = [[UIAlertView alloc]initWithTitle:@"" message:@"There is no active membership matching this information. If you are a past member, please make sure your membership is paid for the current year." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"My Account", nil];
[notActiveAlert show];
}
});
}
}
- (void)fetchData:(NSData *)responseData {
NSError *error;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
for (int i = 0; i < jsonArray.count; i++) {
NSDictionary *jsonElement = jsonArray[i];
self.responseStatus = jsonElement[@"STATUS"];
self.responseFirstName = jsonElement[@"FIRST_NAME"];
self.responseLastName = jsonElement[@"LAST_NAME"];
self.responseNumber = jsonElement[@"MEMBERSHIP_NUMBER"];
}
[self.loadingIndicator stopAnimating];
[self.checkInfoButton setHidden:NO];
}
- (void) myKYFB {
KFBAppDelegate *appDelegate = (KFBAppDelegate *)[[UIApplication sharedApplication]delegate];
KFBNavControllerViewController *navController;
MyKYFB *myKYFB = [[MyKYFB alloc]initWithNibName:nil bundle:nil];
navController = [[KFBNavControllerViewController alloc]initWithRootViewController:myKYFB];
[UIView transitionWithView:appDelegate.window
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
appDelegate.window.rootViewController = navController;
}
completion:nil];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[self myKYFB];
}
}
- (void)showMenuList {
[menuClass createMenu];
}
- (void)closeMenu {
[menuClass removeMenu];
}
#pragma mark - TextField Delegate Methods
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.firstName resignFirstResponder];
[self.lastName resignFirstResponder];
[self.membershipNumber resignFirstResponder];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.firstName resignFirstResponder];
[self.lastName resignFirstResponder];
[self.membershipNumber resignFirstResponder];
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
self.firstNameString = self.firstName.text;
self.lastNameString = self.lastName.text;
self.membershipNumberString = self.membershipNumber.text;
}
@end
활동 표시기보기가 스토리 보드와 연결되어 있는지 확인하십시오. –
활동 표시기와 버튼이 모두 xib 파일에 연결되어 있습니다. – raginggoat