Git Product home page Git Product logo

ioscombobox's Introduction

iOSCombobox

This is an iOS control that attempts to replicate the pretty <select> Safari web sites get by default. This control combines the standard UIPickerView with some custom drawing.

Summary

  • Right now, it is only tested on the iPhone. Ideally, the iPad version should display the UIPickerView in a popover window (which it currently does not do.)
  • Probably requires iOS 5+. It was developed against the iOS 6 SDK.
  • Uses ARC.

How to Use

  1. Import iOSCombobox.h and iOSCombobox.m into your project.

  2. To programatically create a combo box, put something like this in your view controller initialization routine:

    CGRect myRect = CGRectMake(10.0f, 10.0f, 300.f, 32.0f);
    // Note: for now, 32 pixels is the recommended height of the control
    
    iOSCombobox *myCombo = [[iOSCombobox alloc] initWithFrame:myRect];
    [myCombo setValues:@[@"Hello", "World"]];
    [myCombo setCurrentValue:@"World"];
    [self.view addSubview:combo];
    
  3. Adding from the interface builder may also be possible. I imagine it's as simple as adding a "view," then changing the type of the view to be JMWCombobox. I'll be testing that soon. I just wanted to get this readme written.

Using with BSKeyboardControls

If you're wanting to use this with BSKeyboardControls, you'll need to make a quick addition to their code. I've included the modified versions of BSKeyboardControls.h and BSKeyboardControls.m in this repository. Basically, in the…

- (void) setFields:(NSArray *)fields

method, you'll need to add an additional case to the "if" block you see within the "for" loop to accomodate the fact that this combo box is not a text field or a text view. You'll add…

else if ([field isKindOfClass:[JMWCombobox class]])
{
	[(iOSCombobox *)field setInputAccessoryView:self];
}

Another possible fix to this solution is simply asking the field if it responds to setInputAccessoryView. That way, you won't need to expand on this method whenever you want to add a different kind of control.

Help Wanted

  • Modernizing the drawing. I'm fairly new to iOS, but most of the example code out there is for older Core Graphics stuff. I can't tell you how many times I encountered an accepted Stack Overflow answer with a comment of "there is now a better way to do this." If anyone has suggestions on improving the draw method, please feel free to fork and submit a pull request.
  • iPad support. (Though I'll eventually have to do this myself)

License

This is MIT licensed. Have at it!

ioscombobox's People

Contributors

jakemwood avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.