开发者

Setting navigationItem.leftBarButtonItem - why does it hide my back arrow button?

开发者 https://www.devze.com 2022-12-23 12:10 出处:网络
When I do this : // --------------- SETTING NAVIGATION BAR LEFT BUTTON activityIndicator = [[UIActivityIndicatorView alloc] initWi开发者_开发技巧thFrame:CGRectMake(0.0,0.0,25.0,25.0)];

When I do this :

    // --------------- SETTING NAVIGATION BAR LEFT BUTTON
    activityIndicator = [[UIActivityIndicatorView alloc] initWi开发者_开发技巧thFrame:CGRectMake(0.0,0.0,25.0,25.0)];
    [activityIndicator sizeToFit];
    activityIndicator.autoresizingMask =
    (UIViewAutoresizingFlexibleLeftMargin |
     UIViewAutoresizingFlexibleRightMargin |
     UIViewAutoresizingFlexibleTopMargin |
     UIViewAutoresizingFlexibleBottomMargin);

    UIBarButtonItem *loadingView = [[UIBarButtonItem alloc] 
                                    initWithCustomView:activityIndicator];
    //loadingView.target = self;
    self.navigationItem.leftBarButtonItem = loadingView;
    [activityIndicator startAnimating];
    // ---------------

It hides my back arrow button (the one I use to get back to the previous controller) ... why is that ?!?

How am I supposed to add my activityIndicator next to my back arrow ? (i already used titleView and rightbarbuttonitem)


The leftBarButtonItem is by default the back arrow. When you set it to something else, then you lose the built in back button.

If you need a custom back button with a activity indicator than you will have to provide it yourself and then when the button is pressed you need to call

[self.navigationController popViewControllerAnimated:YES];
0

精彩评论

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