In the AppDelegate I'm setting custom back button background image with UIAppearence.
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:highlightedImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
In some cases after pushing view controller appears default back button background image over my custom.
It helped me to hide default image.
[[UINavigationBar appearance] setTintColor:[UIColor clearColor]];
Related
In an iPad app I'm writing I have button in a static table cell that launches an image picker inside a popover.
I want the popover's arrow to point at the button that launched the popover. Right now, when I tap the button it doesn't. It throws the popover on screen (with the working image picker) but the arrow either points to the top of the screen or kind of anywhere else (can't figure out if it's random or not--see below).
The tableview that holds the static cell that contains the button has its scroll disabled but is located on a scroll view. Could that cause random arrow locations?
Here is my code:
// present image picker in a popover
_imagePicker = [[UIImagePickerController alloc] init];
_imagePicker.delegate = self;
_imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
_imagePicker.allowsEditing = NO;
_imagePicker.navigationBar.tintColor = [UIColor redColor];
_imagePicker.navigationBar.backgroundColor = [UIColor greenColor];
_popover = [[UIPopoverController alloc] initWithContentViewController:_imagePicker];
[_popover presentPopoverFromRect:self.theButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Can someone please explain why the arrow isn't pointing at the button's frame and/or how to fix it?
Thanks.
The button is likely not a direct subview of self.view.
Try:
[_popover presentPopoverFromRect:self.theButton.frame inView:self.theButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Is it possible to create a button inside a TableView in ios 6?
An example would be in Settings --> Mail, Calender... --> Click on an existing email account (on iPhone). At the bottom of this view there is a "button' saying delete account.
Is this a button or just another cell made to look like a button?
I want to keep the standard background that comes with a TableView which is why I'm inquiring. I know I could make the TableView shorter and add a normal button.
Thanks
Check out my code on GitHub. https://github.com/eddieios/ECFormView
ECFormView uses a UITableView with a button added to the tableFooterView. I put the pertinent code below.
UIView *footerView = [[UIView alloc] init];
[footerView setFrame:CGRectMake(0, 0, 320, 100)];
self.tableView.tableFooterView = footerView;
[self.tableView sendSubviewToBack:footerView];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[footerView addSubview:button];
[button setFrame:CGRectMake(10, 10, 300, 44)];
[button setTitle:#"Submit" forState:UIControlStateNormal];
//[button addTarget:self action:#selector(nextView:) forControlEvents:UIControlEventTouchUpInside];
You can do this by adding a button as a subview to the tableHeaderView or tableFooterView of a table view. This SO post describes some of the implementation: Adding a UIButton in the header of UITableView header
iOS 6 added a UITableViewHeaderFooterView class that implements a reusable view for headers and footers. This can improve performance when dealing with large table views. See: How to use UITableViewHeaderFooterView?
First of all I explain what i am doing. I created a navigation based application. I have to add a custom image in the navigationbar. I added the image by using -
[self.navigationController.navigationBar insertSubview:image atIndex:0];
After this i added two custom buttons left and right to the navigation bar of the same view.I have another view and on this view i also added two custom buttons left and right to the navigation bar. All is fine till now but as i navigate to my second view my custom buttons that i am adding to the navigation controller on viewwillappear doesn't show. I used this code to add custom buttons to navigation bar -
UIBarButtonItem *customHome = [[UIBarButtonItem alloc] initWithCustomView: buttonHome];
[self.navigationController.navigationItem setLeftBarButtonItem:customHome];
Please suggest what's wrong in this. :(
You're trying to set the navigationItem on the navigation controller instead of the view controller.
If you have embedded your UIViewController in a UINavigationController then in viewDidLoad of the View Controller you could, for example, make the title a UISearchBar (that you dragged to the UIViewController in Xcode IB) and put 2 buttons on the right like this:
UIBarButtonItem *componentsButton = [[UIBarButtonItem alloc] initWithTitle:#"components" style:UIBarButtonItemStylePlain target:self action:#selector(componentsButtonTapped:)];
UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithTitle:#"settings" style:UIBarButtonItemStylePlain target:self action:#selector(settingsButtonTapped:)];
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:componentsButton, settingsButton, nil];
self.navigationItem.titleView = searchBar;
The issue here is the distinction between UINavigationController, which manages UINavigationBar, and UINavigationItem, which you and UINavigationController co-manage. (Don't forget the UINavigationBarDelegate protocol, which has little used but useful methods.)
I've spent the last three hours here on StackOverlow and the rest of the day on Google but unfortunately I can't figure out what I'm doing wrong.
I'm in a view launched by presentModalViewController: in this view I got some buttons and one is calling an IBAction method who will open UIImagePickerController instance modally.
Until here it's all ok: what I'd like to do is make a custom UIToolBar with 3 button (to open Photo Library, Make a photo, Cancel). I did a new UIView with these objects and I thought I could add in this way:
picker = [[UIImagePickerController alloc] init];
[picker setDelegate:self];
[picker setAllowsEditing:NO];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
CGRect overlayFrame = CGRectMake(0, 436, 320, 44);
cameraOverlayView.frame = overlayFrame;
picker.showsCameraControls = NO;
picker.cameraOverlayView = cameraOverlayView;
[self presentModalViewController:picker animated:YES];
I see my custom toolbar at the bottom, but on top of this there's a white space until the UIImagePickerController of the camera: for what I see, the sum of the blank space and my UIToolBar is equal to the CameraControls (turned off).
When I tap on "photo library" button, I can choose a picture, it works but starting from that point I will see the white space on the parents Views (after the dismissModalViewController:animated).
I can't see a way to fix this.
The most similar topic I found is this:
ModalViewController loading on top of another Modal
but it doesn't help or work for me.
Any help, at this point, would be very appreciated.
Thank you.
Fab
I use the TTLauncherView in my project. To have a custom navigation bar background I have subclassed the UINavigationBar in my app delegate. This works fine and all navigation bar's now have this custom style.
#implementation UINavigationBar (CustomNavBarBG)
-(void)drawRect:(CGRect)rect{
UIImage *image = [UIImage imageNamed:#"navbar_s.png"];
[image drawInRect:self.bounds];
}
#end
When navigating through the views the title appears in the middle of the bar. But on the navigation bar of the main screen, the launcher, I want to have an image instead of the title. Is this possible?
How to implement it?
you can override the default title view when you load your controller with a custom UIView, such as a UIButton:
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *logoView = [[[UIButton alloc] initWithFrame:CGRectMake(0,0,85,40)] autorelease];
[logoView setBackgroundImage:[UIImage imageNamed:#"navBarLogo.png"] forState:UIControlStateNormal];
[logoView setUserInteractionEnabled:NO];
self.navigationItem.titleView = logoView;
}
I'm actually not sure why I used UIButton here :-) maybe you can use a UIImageView instead, but this code works fine.