QKForms 0.0.9

QKForms 0.0.9

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2014年12月

Eric Webster 维护。




QKForms 0.0.9

  • Eric Webster

自动处理将文本字段和文本视图移出键盘的方式。还处理将文本视图扩展到适合其文本的大小。与设备朝向无关。

QKForms 在行动!

使用方法

这是一步一步使用 QKForms 与界面构建器的指南。这些步骤所引用的演示包含在 QKFormsDemo 中。

第一步

创建一个滚动视图(或表格视图,或集合视图),并将 QKFormsScrollView 类添加到其中。

第二步

如果您希望具有在您键入时扩展并移出键盘的文本视图,请将 QKAutoExpandingTextView 类添加到您的文本视图中。

第三步

添加任意数量的文本字段、搜索栏,全部在另一个视图中,随意!

就这样!

您设计好表单后,所有内容都会自动处理。任何具有类 QKAutoExpandingTextView 的文本视图都会随着键入而扩展

而且类 QKFormsScrollView 处理将其文本字段和文本视图移出键盘的方式。它还处理在收到点击手势时隐藏键盘。

选项

每个 QKFormsScrollViewQKFormsTableViewQKFormsCollectionView 都有如下接口

// Options, which can be found in the QKFormsOptions class.
@property (nonatomic, readonly) QKFormsOptions *options;

// An optional property which will be sent the TouchUpInside event
// when return is pressed while editing the last field in the form.
// The options property returnShouldMoveToNextField must be set to YES in order
// to use this.
@property (nonatomic, weak) IBOutlet UIButton *submitButton;

// Navigates to the next field, based on vertical position.
- (IBAction)nextField;

// Navigates to the previous field, based on vertical position.
- (IBAction)previousField;

- (IBAction)dismissKeyboard;
- (void)dismissKeyboardWithCompletion:(void (^)(void))completion;

您可以通过 QKFormsOptions 设置一些选项

// Whether return navigates to the next field or not.
// Default: YES
@property (nonatomic, assign) BOOL returnShouldMoveToNextField;

// In text views, whether return should insert a newline character.
// This overrides returnShouldMoveToNextField for text views.
// Default: NO
@property (nonatomic, assign) BOOL returnShouldInsertNewline;

// The margin between the keyboard and the field being edited.
// Default: 20
@property (nonatomic, assign) CGFloat keyboardTopMargin;

// Whether the form view displays a shadow when its content overflows.
// In order for this to work, this view must have a superview with the same bounds.
// Default: YES
@property (nonatomic, assign) BOOL showsShadow;

// This will force the field to be pulled down towards the keyboard, even
// if it is already above the keyboard.
// Default: NO
@property (nonatomic, assign) BOOL shouldFocusFields;

QKForms 提供了一个名为 QKAutoExpandingTextViewUITextView 子类,它自动将其扩展以适应它所给的文本。它可以设置一个最大高度

// If maxHeight is a number other than 0, this view will not expand beyond maxHeight.
@property (nonatomic, assign) CGFloat maxHeight;

另一个有用的视图叫作 QKPlaceholderTextView,它是 QKAutoExpandingTextView 的一个子类,它允许在文本视图中设置提示文本。