I want to have a UISegmentedController but the user can choose the segment and change the text inside. Is there any way to do that?
Thanks.
EDIT: This is what I would like to do. I have users which choose an option using UISegmentedControl. Under settings, I would like to give them the opportunity to modify what the texts in the UISegmentedControl is. I can use a UITextField and a button which triggers the change but I didn't like that solution. I considered putting a UISegmentedControl image with UITextField inside each segment but that does not seem like an elegant solution. Besides, I have no idea what the font is being used in UISegmentedControl. If I am not mistaken, by default, you can only fit a maximum of 12/13 chars or else it can break. iOS 5 SDK has some more methods to customize so it may be possible.
I coded a solution which involves a preview of what the UISegmentedControl will look like, 2 textfields to replace the texts inside each segment and a button which saves the value. I scraped it because I did not like the implementation and I just didn't like the execution too. I wanted the users to feel like they are using the UISegmentedControl and able to edit the texts inside it, up to a max of 12/13 chars.
Thanks.
You can always dynamically change the values of the segmented controller in code. Would it be acceptable to have the user click the button, at which point you could pop up a form for the user to fill in with the new value, and then call this method on the segmented control:
- (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment
Related
I'd like to show information in a second view that's contextualized to what's appearing in the first view. To do that, I'd like to get just the text that's scrolled into view in the NSView. As in the picture I've attached, the whole document is A. The portion that's visible is B. I'm writing this using Objective-C and Swift, so a suggestion in either language would be welcome. Thank you.
This question already has an answer here:
NSTableView with +/- buttons like in System Preferences using only Interface Builder
(1 answer)
Closed 7 years ago.
I'm building an OSX app and want to create a set of controls similar to what's found at bottom of the standard Network Preferences configuration panel. I'm running into some layout problems that I wouldn't have expected.
These are my specific questions:
What contains the 3 buttons so there's similar shading all they way across the row where the buttons are positioned? In particular, what's causing the area without buttons to have shading?
How do you do this without getting a double border where the row of buttons meets up with the table?
I want to do this with an xib file. This may be incredibly simple, but I'm missing something I guess.
I find that if you make a button with style "Gradient" and type "Momentary Change", then it looks like the other buttons but does not respond to clicks, so you can use that as the area after the last button. (The NSMomentaryChangeButton is documented as changing the image and title when clicked, so if you don't use an image or title, nothing should change.)
If you check Refuses First Responder in the attributes inspector, then it will not be possible to highlight this blank button using Full Keyboard Access.
Ken Thomases also brings up the issue of the blank button being shown as a button to Accessibility. One can fix that by using a subclass of NSButtonCell that has just one method:
- (BOOL)accessibilityIsIgnored
{
return YES;
}
I think that's easier than writing a custom view.
As d00dle says, avoid double borders by slightly overlapping things.
Since you want the slack space to have the same background as the buttons, and since the buttons can change appearance from release to release of the OS, the best thing to do is to get the frameworks to draw it like it would the buttons.
Rather than using an actual button as JWWalker suggests, I have used a custom view that leverages NSButtonCell to draw the background. The advantage is that you can be sure there's no chance of getting undesirable behavior. For example, a button could get focus (for users who have All Controls selected in System Preferences > Keyboard > Shortcuts > Full Keyboard Access) so that the user could Tab to it. Accessibility will report the presence of the button through VoiceOver. Etc.
Configure the button cell just like the buttons (set buttonType and bezelStyle). In the view's -drawRect: call [buttonCell drawWithFrame:rect inView:self];, where rect is similar to the frames of the buttons. Since one way to avoid double borders is to make the buttons larger than the view's bounds, you may need to do the same for rect. For example, you might want to use NSInsetRect(self.bounds, -1, -1).
The buttons are buttons... This can be accomplished with a custom view drawing border and the background "shading".
To avoid the double border where the table and the custom view meet you simply align it so they overlap by 1 point (pixel) or avoid drawing the top border in your custom view.
I don't know of any standard object capable of doing this.
I would like to add a little red dot to a UITabBarItem in my TabBarController to indicate that a certain condition is triggered (in this case the content is filtered), much like Mail little number in Dock indicating how many unread mails you have.
Seems that this cannot be done looking at the Docs. So maybe there is another approach that can use to get this done.
Since the TabBar is always locked at the bottom of the screen I just can overlay another view on top but I am willing to know if there is a smarter way.
Use the badgeValue property of UITabBarItem. Read about it here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarItem_Class/Reference/Reference.html#//apple_ref/occ/instp/UITabBarItem/badgeValue
I'm creating a view which provides some fields for the user to fill in - address, phone number etc.
I've seen apps that have populated fields with grey text like 'Fill in your name here' on the Name field, and when the user taps on it the text is gone, a keyboard appears and the view is zoomed in to the textfield(or whatever it is). Also, after filling up that field tapping the 'Next' button on the keyboard brings the user to the next field. I'm trying to do the same but I have no idea where to get sources on this. Pardon my poor googling skills ;p
Tried UITextView and UITextField but there isn't anything related to this on the Interface Builder. Figured it lies with the codes?
It'd be great if I can get some explanation or some links on how this works (: Thanks!
EDIT: okay I played around with the Interface Builder a lil more and realized I could set placeholder as the grey text.
It is in fact a UITextField.
You can get the greyed out text by setting its placeholder property.
I am not sure what you mean by zooming but usually they do use a scroll view or adjust the frame so that it isn't blocked by the keyboard.
The Next button is made available using a UIToolbar instance as the text field's inputAccessoryView. However the implementation is one's own and is not framework provided. You can look at this example to get started.
How can I get a UIButton like the ones at the bottom of this picutre (move and delete)? Specifically, I want an image with a text just like that. http://4.bp.blogspot.com/_QLwms0mVa4w/SQN0MqPIpXI/AAAAAAAAAA8/lEikKn9eP_0/s1600-h/Screenshot+2008-10-25+15:31:21+-0400-1.png
Thanks.
For Jason:
The image sticks right beside the label. Is there anyway from IB I can set it to align to the left, while the label aligns to the right? Here's what it looks like right now:
What you can do is in Interface Builder, the UIButton can be set to a type of "Custom"
After you have done this, you can simply use your own image for the button and different images for each state of the button.
Although with this approach you won't be able to have additional text modified on it like the mail app has with "Delete (1)". However, if you don't need that then this solution will work for you.
Alternatively, if you just want an image stuck onto your existing button then there is an Image property in Interface Builder where you can slap on an image to your button.
If you need more functionality then you would probably have to create your own UIButton by subclassing to handle it.