How can I build a multi-selectable segmented control like Apple's pages uses to choose the font style (eg Bold, Italic or Underlined)?
Is the segmented control the correct way or is there a better one?
Thanks,
Mica
What I would do is just use a toggle button for each property. You should use UISwitch for this.
If you don't want to use a UISwitch and prefer a more traditional approach to a toggle button, have a look at these answers. I don't think a segmented control is the way to go at all. The segmented control only has one selected state and it would go against apple's UI guidelines to use it for multiple selected states.
Apple does this very thing in the Xcode GUI; note the multi-select segmented control in the upper right for View. Here's a link for OSX, that might get you closer to an iOS solution
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSegmentedCell_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSSegmentSwitchTrackingSelectAny
See the value NSSegmentSwitchTrackingSelectAny
Related
I'm not sure exactly what keyword I should be searching, but I wasn't able to find the answer to my problem - I'm new to iOS development so apologies in advanced if I'm not using the correct UI components.
I want to create something like a segmented control (two choices) with multi-line descriptions in them, except I'm not sure if I should be using a segmented control to do so, or to customize a button to create it. The user should be able to select a "choice" and that will switch views and tint the choice not selected depending on the choice the user makes. How exactly would I design this / is this possible?
I've already attempted to modify the segmented control but couldn't get the desired results. I've thought about creating a text box and modifying it to act like a button selector, but wasn't sure if that was the best way. I would love some input, thanks!
I can select multiple font styles in Apple Pages app, orange colored box on the screen.
How to make it?
I can't find any ui component in the iOS SDK like this, multiple select. UISegmentControl is only for one select like radio button.
use a UISegmentControl in momentary mode to have the bar :)
set custom background images for the cells
there is no stock control but this is quite basic using this approach
No default thing is available you have to do it by yourself. You set tags for each button and only one selector. By checking the selected button tags execute you specific code.
For that, yon need to take UISegment Control and make it's background images custom. Also you can set the width of the each segment.
Then you will achieve your goal.
Cheers!
I am trying to make an update for my trivia app and want it so that when the user types in the answer he/she only has the option to click A,B,C, or D. Is this possible? and if so, would apple allow this and how do I do it?
You could also just create a custom view with four buttons that appears when necessary. It would be easier than customizing the keyboard, and depending on how you design and implement it, it'll probably look better than an action sheet. UIView provides a rich set of methods to animate views with ease.
Yes, you can customise the keyboard, all the documentation is in the developer library. But it sounds to me you'd be better off using a UIActionSheet if all you are doing is picking from four options.
Edit: For reference, have a look at Custom Views for Data Input in Apple's Text Programming Guide for iOS.
Im using Monotouch.Dialog. I'd like to customise the look and feel of the tables. Nothing too major, I can change the background of the tableview easily, the cell borders and use my own custom header and footer views.
What is the best way of customising ALL the cells displayed in a TableView?
Is there some point in the Monotouch.Dialog code I can intercept the generation of cells and customise them in one place, so they all, for example have the same background color, font type/color custom detail disclosure icon etc.
Or do I have to individually customise all the different types (BooleanElement, StringElement, FloatElement etc)
Note: Im aware I can use StyledString element, but this only covers the string element type. I want to customise all the cells displayed in my own custom style.
There is no easy way of doing this in the current codebase for MonoTouch.Dialog.
What you could try is the Beta for MonoTouch which comes with iOS5 bindings. If you are willing to only support iOS5, you can use the Appearance class to customize a few properties (not all, sadly). You can customize things like the background view across the board:
UIView.Appearance.BackgroundColor = UIColor.Red;
You could also take a look at https://github.com/RobertKozak/MonoMobile.Views which started as a fork from MonoTouch.Dialog but morphed into a similar but now totally different library. It has styling built in.
Lets say my UISegmentedControl has 8 numbered segments. I would like for the user to be able to turn on 2, 3, or more of them at once. Toggling them. Essentially like a bits in a byte. Is this possible? I believe it is on regular Mac OS X but I can't seem to find a way to do it in the iPhone SDK.
If I have to simulate this by putting buttons into a view, is there any way to do the following:
Round the corners of the view so that it looks like the "bar" style UISegmentedControl?
Use the built-in backgrounds the "bar" style has on the buttons?
Give the buttons a shadow like the whole "bar" style has? (not the text)
Update: The custom control I mentioned here no longer works under iOS 13.
This is the best custom control I've found that allows multiple segments to be selected concurrently:
https://github.com/yonat/MultiSelectSegmentedControl
This one is a subclass of UISegmentedControl, which is convenient. I've forked it here:
https://github.com/stewartmacdonald/MultiSelectSegmentedControl
and added some code examples to the ReadMe and added a method that allows you to get an NSArray of the titles of all selected segments.
This isn't possible using UIKit. I would recommend creating a custom control, or an array of UISwitch controls, representing each of the options in your UISegmentedControl.
I think the simplest way is to create your own segmentedcontrol with UIButton.
Marco
There appears to be a way to do this in XCode now. In the Attributes Inspector, there is a section with Segment, Title, Image, Behavior. The behavior options are "Enabled" and "Selected". You can selecte "Selected" for multiple segments.
I recommend you try https://github.com/tayhalla/THSegmentedControl
it is an actual subclass of UISegmentedControl so it fits nicely with Interface builder and everything.