uinavigationitem

Get the frame of UIBarButtonItem in Swift?

梦想与她 提交于 2019-11-27 23:33:22
how could I get the frame of a rightbarbuttonItem in swift? I found this : UIBarButtonItem: How can I find its frame? but it says cannot convert NSString to UIView, or cannot convert NSString to String : let str : NSString = "view" //or type String let theView : UIView = self.navigationItem.rightBarButtonItem!.valueForKey("view")//or 'str' The goal is to remove the rightBarButtonItem, add an imageView instead, and move it with a fadeOut effect. Thanks Christian Wörz You should try it like: var barButtonItem = self.navigationItem.rightBarButtonItem! var buttonItemView = barButtonItem

navigationController.navigationItem vs navigationItem

我只是一个虾纸丫 提交于 2019-11-27 23:28:47
Just curious, why setting self.navigationItem = ... works, but self.navigationController.navigationItem fails? The same applies for self.toolbarItems vs self.navigationController.toobarItems . When to use self.navigationController.navigationItem ? Maybe you will say, they point to different things. but why self.navigationController.navigationBarHidden = YES the navigation bar is hidden. doesn't it means self.navigationController.navigationItem point to the bar i wanted? The class UIViewController has a property navigationItem . This is true of all the subclasses too whether it is a

Setting Bar Button Item color in a custom navigation bar

岁酱吖の 提交于 2019-11-27 22:42:15
问题 I created a custom navigation bar and a right navigation button using the XIB. This works fine. But I need to to customize the tint color of the right navigation button. At the moment this tint color is the same color as tint color of navigation bar. I need a different color for this right button. Is there any way to change this color? Thank you. 回答1: Not to my knowledge, the button inherits the tint color of the navigationBar. What you can do is set a customView for the navigationItem: This

vertically aligning UINavigationItems

邮差的信 提交于 2019-11-27 22:28:57
I have customized the UINavigationBar's height to 100px and I'd like to add buttons onto this customized bar. All is good except the button seems to want to sit on the bottom of the nav bar no matter what. I can't get it to align to the center or the top of the nav bar. Here is the code; first I create a navigation controller in the app delegate and add one button on the right. // set main navigation controller temp *tempc = [[temp alloc] initWithNibName:@"temp" bundle:nil]; self.navigationController = [[UINavigationController alloc] initWithRootViewController:tempc]; UIBarButtonItem *navItem

Change width of a UIBarButtonItem in a UINavigationBar

主宰稳场 提交于 2019-11-27 21:16:52
I am creating a UIBarButtonItem and adding it to my navigation bar like so: (void)viewDidLoad { ... // Add the refresh button to the navigation bar UIButton *refreshButton = [UIButton buttonWithType:UIButtonTypeCustom]; [refreshButton setFrame:CGRectMake(0,0,30,30)]; [refreshButton setImage:[UIImage imageNamed:@"G_refresh_icon.png"] forState:UIControlStateNormal]; [refreshButton addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *refreshBarButton = [[[UIBarButtonItem alloc] initWithCustomView:refreshButton] autorelease]; self

UINavigationItem Back Button touch area too large

旧街凉风 提交于 2019-11-27 18:40:38
问题 On this following screenshot, if I click on "v" from "Available Kiosks" this is launching the action of the back button... (not with the second "a"). I don't understand why, I've nothing special in my code (this is the default backbutton handled by the navigation controller). I also have the same bug with another application I did but I never notice this on others applications. Any Ideas ? Thank you. 回答1: That's not a bug, it does the same in Apple apps, and even on some (many / all ?)

Custom back button on navigation bar

旧街凉风 提交于 2019-11-27 15:07:33
问题 In my application there are many UIViewControllers with UINavigationControllers . There must be a "back" button and a "home" UIButton on the UINavigationBar . All of this works fine. But some of my UIViewControllers have long names, and sometimes there is too small place left for it. I'm trying to replace the original label of the "back" button (it shows the title of the previous view) with a custom "Back", but whatever I tried it didn't work: // Title didn't change [self.navigationItem

Adding back button to navigation bar

▼魔方 西西 提交于 2019-11-27 14:08:06
I've added a navigation bar to a UIViewController. It is displayed from another UIViewController only. I'd like to have a left side back button that is shaped similar to an arrow, just like the normal navigation bar back button. It seems I can only add a bar button through IB. I'm guessing the back button needs to be added programmatically. Any suggestions on how I should do this? Currently, in the RootController, I push another UIViewController (viewB) by simply doing an addSubView. In viewB, I want to display the navigation bar. The app is view based, not navigation controller based. If you

How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem?

為{幸葍}努か 提交于 2019-11-27 11:01:00
I got the opposite issue from here . By default in iOS7 , back swipe gesture of UINavigationController 's stack could pop the presented ViewController . Now I just uniformed all the self.navigationItem.leftBarButtonItem style for all the ViewControllers . Here is the code: self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:LOADIMAGE(@"back_button") style:UIBarButtonItemStylePlain target:self action:@selector(popCurrentViewController)]; after that, the navigationController.interactivePopGestureRecognizer is disabled. How could I make the pop gesture enabled without

back button callback in navigationController in iOS

泄露秘密 提交于 2019-11-27 10:18:51
I have pushed a view onto the navigation controller and when I press the back button it goes to the previous view automatically. I want to do a few things when back button is pressed before popping the view off the stack. Which is the back button callback function? ymutlu William Jockusch's answer solve this problem with easy trick. -(void) viewWillDisappear:(BOOL)animated { if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) { // back button was pressed. We know this is true because self is no longer // in the navigation stack. } [super viewWillDisappear:animated];