Add button to navigationbar programmatically

后端 未结 12 1995
日久生厌
日久生厌 2020-12-04 12:03

Hi I need to set the button on right side, in navigation bar, programatically , so that if I press the button I will perform some actions. I have created the navigation bar

12条回答
  •  长情又很酷
    2020-12-04 12:16

    Hello everyone !! I created the solution to the issue at hand where Two UIInterface orientations are wanted using the UIIMagePicker.. In my ViewController where I handle the segue to the UIImagePickerController

    **I use a..

    -(void) editButtonPressed:(id)sender {
       BOOL editPressed = YES;
        NSUserDefaults *boolDefaults = [NSUserDefaults standardUserDefaults];
        [boolDefaults setBool:editPressed forKey:@"boolKey"];
        [boolDefaults synchronize];
    
        [self performSegueWithIdentifier:@"photoSegue" sender:nil]; 
    
    }
    

    **

    Then in the AppDelegate Class I do the following.

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
        BOOL appDelBool;
        NSUserDefaults *boolDefaults = [NSUserDefaults standardUserDefaults];
        appDelBool = [boolDefaults boolForKey:@"boolKey"];
    
           if (appDelBool == YES)
               return (UIInterfaceOrientationMaskPortrait);
            else
                return UIInterfaceOrientationMaskLandscapeLeft;
    }
    

提交回复
热议问题