escoz / QuickDialog

QuickDialog - Quick and easy dialog screens for iOS
http://escoz.com/open-source/quickdialog
Other
3.07k stars 637 forks source link

Radio view pushes the exact same view? #247

Closed ghost closed 12 years ago

ghost commented 12 years ago

I am making an app for my mom that uses QuickDialog, and I had it all working, then I decided to move the code to a viewcontroller, now whenever I go to select a value from the radio view, it just pushes the same view again, and again and again. Ill attach a link to my project, if ANYONE can tell me the problem YOU ARE MY LIFESAVER.

http://www.mediafire.com/?uu89165h2jm2foo

Here is the code form the QuickDialogTreatmentController.m


//
//  QuickDialogTreatmentController.m
//  delta
//
//  Created by Jayden Smith on 23/07/12.
//  Copyright (c) 2012 Agility Media. All rights reserved.
//

#import "QuickDialogTreatmentController.h"

@interface QuickDialogTreatmentController ()

@end

@implementation QuickDialogTreatmentController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    QRootElement *root = [[QRootElement alloc] init];
    root.grouped = YES;
    QSection *personal = [[QSection alloc] initWithTitle:@"Personal Details"];
    QSection *tdetails = [[QSection alloc] initWithTitle:@"Treatment Details"];
    tdetails.footer = @"Only one treatment selection is required.";
    QSection *tdetails2 = [[QSection alloc] initWithTitle:nil];
    QSection *submit = [[QSection alloc] initWithTitle:nil];
    QSection *contactSection = [[QSection alloc] initWithTitle:@"Confirm booking via:"];
    contactSection.footer = @"Confirmation via SMS requires that a valid mobile number be entered into the Contact # field.";

    QEntryElement *fname = [[QEntryElement alloc] initWithTitle:@"First Name" Value:nil];
    fname.autocapitalizationType = UITextAutocapitalizationTypeWords;
    fname.enablesReturnKeyAutomatically = YES;

    QEntryElement *lname = [[QEntryElement alloc] initWithTitle:@"Last Name" Value:nil];
    lname.autocapitalizationType = UITextAutocapitalizationTypeWords;
    lname.enablesReturnKeyAutomatically = YES;

    QEntryElement *email = [[QEntryElement alloc] initWithTitle:@"Email" Value:nil];
    email.keyboardType = UIKeyboardTypeEmailAddress;
    email.enablesReturnKeyAutomatically = YES;

    QEntryElement *mnumber = [[QEntryElement alloc] initWithTitle:@"Contact #" Value:nil];
    mnumber.keyboardType = UIKeyboardTypePhonePad;
    mnumber.enablesReturnKeyAutomatically = YES;
    mnumber.key = @"decimal1";

    QTextElement *treatmentNote = [[QTextElement alloc] initWithText:@"Please only select up to five different treatments through the online booking system. If you wish to book more than five treatments, please give us a call."];
    treatmentNote.font = [UIFont boldSystemFontOfSize:12];

    QMultiRadioElement *treatment1 = [[QMultiRadioElement alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Deep Clense Facial", @"Deluxe Ampoule Therapy Facial", @"Petite Facial", @"Hydra Facial", @"Bio Herbal Peel", @"", @"Half Leg Student - Wax", @"Half Leg - Wax", @"Half Leg & Bikini - Wax", @"Three Quarter Leg - Wax", @"Full Leg - Wax", @"Full Leg & Bikini - Wax", @"Full Leg & Brazillian - Wax", @"Half Leg & Brazillian - Wax", @"Underarm - Wax", @"Half Arm - Wax", @"Full Arm - Wax", @"Lip or Chin - Wax", @"Lip & Chin - Wax", @"Eyebrow Shape - Wax", @"Eyebrow Shape & Lip - Wax", @"Lip, Chin & Eyebrow - Wax", @"Bikini (Standard) - Wax", @"Bikini (Extended) - Wax", @"Brazillian - Wax", @"Threading", @"", @"Male - Full Back & Sholders - Wax", @"Male - Chest & Stomach - Wax", @"Male - Full Leg - Wax", @"", @"Eye Lash - Tint", @"Eyebrow - Tint", @"Lash & Brow - Tint", @"Lash & Brow - Tint + Eyebrow Wax", @"Eyebrow - Tint & Shape", @"", @"Special Occasion - Makeup", @"Student - Makeup", @"Bride - Makeup", @"Mridesmaids - Makeup", @"Mother of Bride - Makeup", @"Travel - Makeup", @"", @"Polish only", @"Express Manicure", @"Manicure", @"Satiny Hands Manicure", @"Express Pedicure", @"Pedicure", @"", @"Gentle Relaxation Back Massage", @"Full Body Relaxation Massage", @"Hot Stone Therapy Massage (40 min)", @"Hot Stone Therapy Massage (60 min)", @"Hot Stone Therapy Massage (75 min)", @"",   @"Full Body - Spray Tan", @"Maintenance - Spray Tan", @"Half Body - Spray Tan", @"", @"Intense Pulse Light (IPL)", @"", @"Micro-dermabrasion - Treatment", @"Micro-dermabrasion - 6 Weekly Treatments", @"", @"Eylash Extensions Initial Application", @"Eyelash Extensions Infills", nil] selectedIndexes:[NSArray arrayWithObjects:[NSNumber numberWithUnsignedInteger:1],[NSNumber numberWithUnsignedInteger:2], nil] title:@"Treatment/s"];
    treatment1.key = @"treatradio";

    QDateTimeInlineElement *datetime = [[QDateTimeInlineElement alloc] initWithTitle:@"Date/Time" date:[NSDate date]];
    datetime.mode = UIDatePickerModeDateAndTime;

    QTextElement *timenote = [[QTextElement alloc] initWithText:@"If you wish, you may enter an alternate Date/Time. If the Date/Time you selected in not available, we will check the alternate for availability."];
    timenote.font = [UIFont boldSystemFontOfSize:12];

    QDateTimeInlineElement *altdatetime = [[QDateTimeInlineElement alloc] initWithTitle:@"Alternate" date:[NSDate date]];
    altdatetime.mode = UIDatePickerModeDateAndTime;

    NSArray *component1 = [NSArray arrayWithObjects:@"Julie-Anne", @"Janis", @"Abbie", @"Hollie", @"Emily", @"No preference", nil];
    QPickerElement *therapist =
    [[QPickerElement alloc] initWithTitle:@"Preferred Therapist"
                                    items:[NSArray arrayWithObject:component1]
                                    value:nil];

    QSegmentedElement *contactMethod = [[QSegmentedElement alloc] initWithItems:[[NSArray alloc] initWithObjects:@"Email", @"Phone", @"SMS", nil] selected:1 title:@"Contact Via"];
    contactMethod.key = @"segmented1";

    QButtonElement *button = [[QButtonElement alloc] initWithTitle:@"Submit Booking"];
    button.onSelected = ^{

        NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
        [root fetchValueIntoObject:dict];

        NSString *msg = @"Values:";
        for (NSString *aKey in dict){
            msg = [msg stringByAppendingFormat:@"\n- %@: %@", aKey, [dict valueForKey:aKey]];
        }

        NSLog(@"%s", __FUNCTION__);
        //Allocate NSURL object
        NSURL *nsURL = [[NSURL alloc] initWithString:kTextUrl];
        // Allocate NSMutableURLRequest
        NSMutableURLRequest *nsMutableURLRequest = [[NSMutableURLRequest alloc] initWithURL:nsURL];
        // Set HTTP method to POST
        [nsMutableURLRequest setHTTPMethod:@"POST"];

        // Set up the parameters to send.
        NSString *paramDataString = [NSString stringWithFormat:@"fname=%@&lname=%@&email=%@&mnumber=%@&treatment1=%@&datetime=%@&altdatetime=%@&therapist=%@&contactMethod=%@", fname.textValue, lname.textValue, email.textValue, mnumber.textValue, treatment1.selectedItems, datetime.textValue, altdatetime.textValue, therapist.textValue, contactMethod.selectedItem];
        NSLog(@"%s - paramDataString: %@", __FUNCTION__, paramDataString);
        // Encode the parameters to default for NSMutableURLRequest.
        NSData *paramData = [paramDataString dataUsingEncoding:NSUTF8StringEncoding];
        // Set the NSMutableURLRequest body data.
        [nsMutableURLRequest setHTTPBody: paramData];   
        // Create NSURLConnection and start the request.
        NSURLConnection *nsUrlConnection=[[NSURLConnection alloc]
                                          initWithRequest:nsMutableURLRequest 
                                          delegate:self];
        // Successful connection.
        if (nsUrlConnection) {
        [self performSegueWithIdentifier: @"segueSuccess" sender: self];

        }
        // Unsuccessful connection.
        else {

        [self performSegueWithIdentifier: @"segueFail" sender: self];
        }

    };

    [root addSection:personal];
    [personal addElement:fname];
    [personal addElement:lname];
    [personal addElement:email];
    [personal addElement:mnumber];
    [root addSection:tdetails];
    [tdetails addElement:treatmentNote];
    [tdetails addElement:treatment1];
    [root addSection:tdetails2];
    [tdetails2 addElement:datetime];
    [tdetails2 addElement:altdatetime];
    [tdetails2 addElement:timenote];
    [tdetails2 addElement:therapist];
    [root addSection:contactSection];
    [contactSection addElement:contactMethod];
    [root addSection:submit];
    [submit addElement:button];

    self.root = root;

    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
rustysamurai commented 12 years ago

I had the same issue, in QRadioElement.m change to this:

worked for me.

ghost commented 12 years ago

You sir, are a lifesaver. Thankyou.