My problem is I have to change UIButton backgroundcolor on click and navigation controller move to next page.
I don't need to use NSTimer to show button effect.
I need to apply this effect for my application all buttons.
I can't able to make my next view controller to wait for show this effect.
If I understand what you're asking correctly, you want all buttons in your application to instantly change background colors upon a button click. You can do this using the UIButton's appearance.
In short, UIAppearance allows developers to easily keep visuals consistent throughout their applications. For more information on what it is and how to use it, click here.
Here's an example:
//Inside of an IBAction that a button clicks
[[UIButton appearance] setBackgroundColor:[UIColor redColor]];
Related
See subject. Is this possible? When I add a tint color with UIButton Appearance... it applies to all UIButtons, not just "System" buttons but even custom ones.
I just want to be able to set a couple of destructive buttons with red text while keeping a customizable tint color for everything else.
Check out UIAppearance appearanceWhenContainedIn.
This one provides way to customize appearance whenever your control is contained within specific view, such as UIToolbar or UINavigationBar. You may check up your own parent view class which contains your custom UIButton.
I have a NSView inside of my "menubar". I have a button where which i click on and add a new NSMenuItem to the menu. However when i run this code which is inside my custom view in the init method sometimes the view will get grayed out and I'm unable to select it. Any ideas what this could be the cause of this. The problem seems to affect all created NSMenuItems after this problem occur.
-(id)initWithFrame:(NSRect)frameRect andTag:(int)tagz{
textfeild = [[NSTextView alloc]initWithFrame:CGRectMake(19,1 , 110, 18)];
[textfeild setFont:[NSFont fontWithName:#"Helvetica" size:15]];
[textfeild setString:[NSString stringWithFormat:#"Notespace %d",tagz]];
[textfeild selectAll:self];
[self addSubview:textfeild];
}
I don't think you are supposed to use [self addSubview:] on a menu item. Instead, you are supposed to create an NSView and place your custom view inside it. Documentation is here: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MenuList/Articles/ViewsInMenuItems.html
However, according to the documentation views inside a menu item may not receive keyboard events. It may work sometimes, but since the documentation specifically mentions it you should not place any view that needs keyboard events inside a menu.
What you should do instead, is avoid NSMenu altogether and simply create an NSWindow where the menu would normally appear. You can make your window look/behave like a menu.
I have a toolBar and I have setup two UIBarButtonItem on it. Both UIBarButtonItem are containing UIButtons as their customViews.
I activate a popover for their Touch Up Inside event as below,
[popover1 presentPopoverFromBarButtonItem:buttonItem1 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
I have another UIButton named clearFilters inside the main view. (Also this is the view which is containing the above toolBar.) I have declared a method for clearFilters button's Touch Up Inside event.
My problem is,
I can not interact with the clearFilters button while a popover is active. So, I'm looking for a solution to interact with this clearFilters button, while a popover is active.
I tried by adding passthroughViews property for a popover as below and it do not work as I expect.
popover1.passthroughViews = [NSArray arrayWithObject:clearFiltersButton];
What could be the reason. As the documentation has mentioned I can not see any issue.
I expect if the above things are correct, then the Touch Up Inside event of the the clearFilters button's should be fire up.
So, please show me if there is any issue or a necessary way to work on this thing.
I'm working on XCode4 and iOS 4.3.
Thanks.
The UIPopoverController documentation reveals why the other bar buttons can be tapped while the popover is visible:
“When presenting the popover, this method adds the toolbar that owns the button to the popover’s list of passthrough views.”
Try querying and logging the popover’s passthrough views. Does it already have things in it? Perhaps something like this would work?
myPopover.passthroughViews = [myPopover.passthroughViews arrayByAddingObject:clearFilters];
I haven’t tested this code, but it’s worth a try.
There is no Done button on a Number Pad-type keyboard. I don't want to add a custom Done button, but how do I dismiss the keyboard?
You could add a UINavigationBar/UIToolBar with a done button(a UIBarButtonItem), and make the textField/textView resignFirstResponder on the done button's action.
You can add the UINavigationBar/UIToolBar as inputAccessoryView of textField/textView.
textField.inputAccessoryView = aNavBarWithDoneButton;
Edit: Availability iOS (3.2 and later)
The simplest solution is to add a new button somewhere in your UI that calls resignFirstResponder on your UITextField (or whatever) when tapped. Putting this in a toolbar is problematic on iPhone because toolbars are typically at the bottom of the screen and obscured by the keyboard.
A slightly more complex solution is to put an invisible UIView behind all of your other tappable UI elements. Any taps not handled by your existing UI will go to this new view, which can call resignFirstResponder on your text field.
If neither of these sound appealing, perhaps you should expand your question to include the type of behavior you want.
What would be the best way to make these buttons? I have no problem with the right/left buttons, but this "tab" functionality is eluding me.
I was thinking of adding custom buttons on viewDidLoad like:
UIButton *profileBtn = [[UIButton alloc] initWithFrame:CGRectMake(50, 5, 100, 30)];
[profileBtn setTitle:#"Profile" forState:UIControlStateNormal];
[self.navigationController.navigationBar addSubview:profileBtn];
However, then the buttons stay on the navigation bar until I manually get them off. Surely there is a better/easier way to do something like this? (note that I'm already using the UITabBarController on the bottom of the screen)
Make use of the UISegmentedControl. Switch views by adding both in the first place and hide/show accordingly. If that eats up too much memory create them just in time and remove the inactive one from the superview.
Here is a tutorial on the UISegmentedControl.