sathya
sathya

Reputation: 135

scrolling doesn't work when alerview with textfield is called in iOS

I am trying to add UITextfield in UIAlertview, so that user can enter the required text and after the submit is clicked the respective datas must send to the webservice.

Viewcontroller is 320*600 frameset, so am having scrollview for displaying the entire content.

While running, when the 'next' button is pressed, alertview with textfield is displayed with no issues, but the moment i click the 'submit' button or 'cancel' button in the alertview, the viewcontroller's scrollview is not working, but the 'back' button in navigation bar for moving to previous controller works good.

Code for alertview with textfield is,

- (IBAction)next:(id)sender
{

UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Enter your changes"
                                                  message:nil
                                                 delegate:self
                                        cancelButtonTitle:@"Cancel"
                                        otherButtonTitles:@"Submit Changes", nil];

[message setAlertViewStyle:UIAlertViewStylePlainTextInput];

[message show];
}

What could be the reason behind this and why the scrollview is not working properly.

UPDATED:

The action for 'submit' button is,

-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
{
    UIAlertView *approval = [[UIAlertView alloc]initWithTitle:@"success" message:@"Your request is updated " delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [approval show];

    text = [[alertView textFieldAtIndex:0] text];
    NSLog(@"passed value %@",text);// text returns the entered value

}
NSURL *url = [NSURL URLWithString:@"http://*******************************"];

NSMutableURLRequest *urlRequest =[[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSString * log= [NSString stringWithFormat:@"key=%@&Action=Preview&deal=%d&status=%d,comment=%@",session,value,11,text];
 [urlRequest setHTTPBody:[log dataUsingEncoding:NSUTF8StringEncoding]];

 [urlRequest setHTTPMethod:@"POST"];

 NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];

if(connection)
{
    NSLog(@"Request for change");
    responseData = [[NSMutableData alloc] init];

}

}

Upvotes: 1

Views: 522

Answers (2)

pooja_chaudhary
pooja_chaudhary

Reputation: 35

Try out this code.link the submit_pressed action to the submit button.On the click of submit a alert view will be popped up and the values will be send the the given url link.After the click of Ok on alert view the normal view will be shown.It has nothing to do with the scroll view.

-(IBAction)Submit_pressed
    {
        UIAlertView *approval = [[UIAlertView alloc]initWithTitle:@"success" message:@"Your request is updated " delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [approval show];

        text = [[alertView textFieldAtIndex:0] text];
        NSLog(@"passed value %@",text);// text returns the entered value

    NSURL *url = [NSURL URLWithString:@"http://*******************************"];

    NSMutableURLRequest *urlRequest =[[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
    NSString * log= [NSString stringWithFormat:@"key=%@&Action=Preview&deal=%d&status=%d,comment=%@",session,value,11,text];
     [urlRequest setHTTPBody:[log dataUsingEncoding:NSUTF8StringEncoding]];

     [urlRequest setHTTPMethod:@"POST"];

     NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];

    if(connection)
    {
        NSLog(@"Request for change");
        responseData = [[NSMutableData alloc] init];

    }

Upvotes: 0

pooja_chaudhary
pooja_chaudhary

Reputation: 35

Just check the actions linked with the cancel and submit button.There might be some mistake in that otherwise the scroll view would have worked.

Upvotes: 0

Related Questions