uisegmentedcontrol

Change NSFetchedResultsController on SegmentedControl change

半城伤御伤魂 提交于 2019-12-18 03:01:45
问题 I've got a UITableView which is filled using a Core Data NSFetchedResultsController . I've now added a UISegmentedControl to the view and when you change the current segment, I'd like the contents of the tableview to change. I've read around online that it would be wise to use two different NSFetchedResultsControllers as then I can benefit from the built-in caching. Only problem is I can't seem to find any sample code for doing this and don't know where to begin. Can anyone explain where to

UISegmentedControl with Image and Title

孤人 提交于 2019-12-18 02:58:09
问题 I am using a UISegmentedControl inside a UIToolBar as button. I can't use a normal UIButtonBarItem , because I need to set the tintColor and support iOS 4.3. So I'm using following code: UISegmentedControl* searchButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"", nil]]; [searchButton setImage:[UIImage imageNamed:@"search_picto"] forSegmentAtIndex:0]; searchButton.momentary = YES; searchButton.segmentedControlStyle = UISegmentedControlStyleBar; searchButton

Two lines of text in a UISegmentedControl

雨燕双飞 提交于 2019-12-18 01:13:09
问题 Try as I might, I can't solve a UISegmentedControl bug for an iOS7 iPhone app. When I create the segmented control, I use this code: NSArray *segmentedControlItemArray = [NSArray arrayWithObjects: @"Nominal:\n27 inch", @"Actual:\n700c x 23mm", @"Actual:\n700c x 20mm", nil]; _wheelDiameterSegmentedControl = [[UISegmentedControl alloc] initWithItems:segmentedControlItemArray]; _wheelDiameterSegmentedControl.frame = CGRectMake(0, 102, 290, 50); _wheelDiameterSegmentedControl.selectedSegmentIndex

Toolbar with “Previous” and “Next” for Keyboard inputAccessoryView

那年仲夏 提交于 2019-12-17 22:23:25
问题 I've been trying to implement this toolbar, where only the 'Next' button is enabled when the top textField is the firstResponder and only the 'Previous' button is enabled when the bottom textField is the firstResponder. It kind of works, but what keeps happening is I need to tap the 'Previous'/'Next' buttons twice each time to enable/disable the opposing button. Am I missing something in the responder chain that's making this happen? Here's my code: - (void)viewDidLoad { [super viewDidLoad];

Is it possible to create multi line UISegmentedControl?

橙三吉。 提交于 2019-12-17 20:14:36
问题 I have a relative longer text items in my segmented control so I need to break text at certain points. Is it possible to use line breaks ? I know at buttons I need to set line break to word wrap, but how to to set it for UISegmentedControl. 回答1: if you have a standard UISegmentedControl you can use the following idea: [_segmentedControl.subviews enumerateObjectsUsingBlock:^(UIView * obj, NSUInteger idx, BOOL *stop) { [obj.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL

How to deselect a segment in Segmented control button permanently till its clicked again

会有一股神秘感。 提交于 2019-12-17 15:25:16
问题 I have a UISegmentedControl with 4 segments. When it is selected, it should maintain the selected state . When the same segment is clicked again, it should deselect itself . How to achieve this? 回答1: Since UISegmentedControl only sends an action if a not selected segment is selected, you have to subclass UISegmentedControl to make a tiny change in its touch handling. I use this class: @implementation MBSegmentedControl // this sends a value changed event even if we reselect the currently

Detect second click on a segment

我们两清 提交于 2019-12-14 02:51:55
问题 According to the documentation, the event which should related to UISegmentedControl is value changed. Assuming I have a segmented control with previous and next, in my case I should be able to click next more than one time, the default behaviour of UISegmentedControl will not recognize the successif second click on same segment. SO how to deal with that? 回答1: Set the momentary property of your UISegmentedControl to TRUE . You can do that in code or in Interface Builder (there is a checkbox

Custom font in UISegmentedControl disable adjustsFontSizeToFitWidth

匆匆过客 提交于 2019-12-14 01:21:49
问题 I have set a custom font for my UISegmentedControl, but it seems to disable the default autoAdjustFontSizeToFitWidth parameter. Before: After: Here is the code I apply to set my custom font: UISegmentedControl *segmentedControl = (UISegmentedControl *)subview; UIFont *font = [UIFont fontWithName:DEFAULT_FONT size:DEFAULT_FONT_SIZE]; NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; [segmentedControl setTitleTextAttributes:attributes forState

UISegmentedControl With AutoLayout Misaligns Title

不羁岁月 提交于 2019-12-13 18:26:34
问题 I have a custom UITableViewCell that has a label on the left side a UISegmentedControl on the right. I'm just getting used to using Auto Layout in code, and this is what I have in my custom cell (using UIView+AutoLayout): -(void)updateConstraints { self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO; self.segmentedControl.translatesAutoresizingMaskIntoConstraints = NO; [self.titleLabel pinToSuperviewEdges:JRTViewPinLeftEdge inset:DB_AUTOLAYOUT_DEFAULT_INSET]; [self.titleLabel

Using IB to add a UISegmentedControl to a NavigationBar

假装没事ソ 提交于 2019-12-13 14:27:17
问题 I'm current creating a UISegmentedControl programmatically in a view controller's viewDidLoad method and adding it to the view controller's navigation bar by assigning it to self.navigationItem.titleView . That's easy enough, but I'd like to be able to do this in Interface Builder as well and so far haven't been able to figure out how. Google hasn't been much help either. Can someone describe how to do this in IB or point to an online example? I'd be much appreciative. Thanks, Howard 回答1: If