开发者

on a button click how to call a class and simultaneously insert values in database

开发者 https://www.devze.com 2023-03-02 01:48 出处:网络
I have an application in which there is a part where on a button click i am inserting values into the database and on the same button action a view controller is being called. This is my code for butt

I have an application in which there is a part where on a button click i am inserting values into the database and on the same button action a view controller is being called. This is my code for button action;

//this is my button action 
-(IBAction)Start:(id)sender{

    Gjourney = mTextJourney.text;
    Glocation = mTextLocation.text;
    Gmessage =mDescription.text;
    // Insert into the database function
    [self saveInDatabase];

    app=(JourneyAppDelegate *)[[UIApplication sharedApplication]delegate];
    //this is the class which i want to get called when i click on the button
    BreadcrumbViewController *st = [[BreadcrumbViewController alloc]initWithNibName:@"BreadcrumbViewController" bundle:nil];

    [app.navController pushViewController:st animated:YES]; 
}

My problem is when t开发者_开发技巧he start button is clicked my data is saved in database but BreadcrumViewController class is not called. What may be the problem?


[self.navController pushViewController:st animated:YES];


-(IBAction)Start:(id)sender{
Gjourney = mTextJourney.text;
Glocation = mTextLocation.text;
Gmessage =mDescription.text;
// Insert into the database function
[self saveInDatabase];

viewcontroller=[ViewController alloc ] initWithNibName:@"ViewController"];
[self.navigationController pushViewController:viewController];
[viewController release];
}

This code should work fine.


Standard view passing is something like this i import the header, then

BreadcrumbViewController *detailViewController = [[BreadcrumbViewController alloc] initWithNibName:@"BreadcrumbViewController" bundle:nil];
        // ...
        // Pass the selected object to the new view controller.
        [self.navigationController pushViewController:detailViewController animated:YES];
        [detailViewController release]; 

If that doesn't work check to see if your navigation controller is ok , you might not have it setup in your delegate

0

精彩评论

暂无评论...
验证码 换一张
取 消