mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-06-12 17:18:58 +08:00
Add RELongTextItem
This commit is contained in:
17
RETableViewManager/Cells/RETableViewLongTextCell.h
Normal file
17
RETableViewManager/Cells/RETableViewLongTextCell.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// RELongTextCell.h
|
||||
// RETableViewManagerExample
|
||||
//
|
||||
// Created by Roman Efimov on 4/11/13.
|
||||
// Copyright (c) 2013 Roman Efimov. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RETableViewCell.h"
|
||||
#import "RELongTextItem.h"
|
||||
|
||||
@interface RETableViewLongTextCell : RETableViewCell <UITextViewDelegate>
|
||||
|
||||
@property (strong, readwrite, nonatomic) RELongTextItem *item;
|
||||
@property (strong, readwrite, nonatomic) UITextView *textView;
|
||||
|
||||
@end
|
||||
91
RETableViewManager/Cells/RETableViewLongTextCell.m
Normal file
91
RETableViewManager/Cells/RETableViewLongTextCell.m
Normal file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// RELongTextCell.m
|
||||
// RETableViewManagerExample
|
||||
//
|
||||
// Created by Roman Efimov on 4/11/13.
|
||||
// Copyright (c) 2013 Roman Efimov. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RETableViewLongTextCell.h"
|
||||
#import "RETableViewManager.h"
|
||||
|
||||
@implementation RETableViewLongTextCell
|
||||
|
||||
+ (BOOL)canFocus
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Lifecycle
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
self.textLabel.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)cellDidLoad
|
||||
{
|
||||
[super cellDidLoad];
|
||||
|
||||
_textView = [[UITextView alloc] initWithFrame:CGRectNull];
|
||||
|
||||
_textView.inputAccessoryView = self.actionBar;
|
||||
_textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
_textView.frame = self.contentView.frame;
|
||||
_textView.backgroundColor = [UIColor lightGrayColor];
|
||||
_textView.delegate = self;
|
||||
[self.contentView addSubview:_textView];
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
|
||||
{
|
||||
[super setSelected:selected animated:animated];
|
||||
if (selected) {
|
||||
[_textView becomeFirstResponder];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cellWillAppear
|
||||
{
|
||||
[super cellWillAppear];
|
||||
|
||||
_textView.text = self.item.value;
|
||||
// _textView.placeholder = self.item.placeholder;
|
||||
_textView.font = self.tableViewManager.style.textFieldFont;
|
||||
_textView.autocapitalizationType = self.item.autocapitalizationType;
|
||||
_textView.autocorrectionType = self.item.autocorrectionType;
|
||||
_textView.spellCheckingType = self.item.spellCheckingType;
|
||||
_textView.keyboardType = self.item.keyboardType;
|
||||
_textView.keyboardAppearance = self.item.keyboardAppearance;
|
||||
_textView.returnKeyType = self.item.returnKeyType;
|
||||
_textView.enablesReturnKeyAutomatically = self.item.enablesReturnKeyAutomatically;
|
||||
_textView.secureTextEntry = self.item.secureTextEntry;
|
||||
}
|
||||
|
||||
- (UIResponder *)responder
|
||||
{
|
||||
return _textView;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark UITextView delegate
|
||||
|
||||
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
|
||||
{
|
||||
[self updateActionBarNavigationControl];
|
||||
[self.parentTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.row inSection:self.sectionIndex] atScrollPosition:UITableViewScrollPositionTop animated:YES];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(BOOL)value
|
||||
{
|
||||
return [[REBoolItem alloc] initWithTitle:title value:value];
|
||||
return [[self alloc] initWithTitle:title value:value];
|
||||
}
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(BOOL)value switchValueChangeHandler:(void(^)(REBoolItem *item))switchValueChangeHandler
|
||||
{
|
||||
return [[REBoolItem alloc] initWithTitle:title value:value switchValueChangeHandler:switchValueChangeHandler];
|
||||
return [[self alloc] initWithTitle:title value:value switchValueChangeHandler:switchValueChangeHandler];
|
||||
}
|
||||
|
||||
- (id)initWithTitle:(NSString *)title value:(BOOL)value
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(NSDate *)value format:(NSString *)format
|
||||
{
|
||||
return [[REDateTimeItem alloc] initWithTitle:title value:value format:format];
|
||||
return [[self alloc] initWithTitle:title value:value format:format];
|
||||
}
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(NSDate *)value format:(NSString *)format datePickerMode:(UIDatePickerMode)datePickerMode
|
||||
{
|
||||
return [[REDateTimeItem alloc] initWithTitle:title value:value format:format datePickerMode:datePickerMode];
|
||||
return [[self alloc] initWithTitle:title value:value format:format datePickerMode:datePickerMode];
|
||||
}
|
||||
|
||||
- (id)initWithTitle:(NSString *)title value:(NSDate *)value format:(NSString *)format
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(float)value
|
||||
{
|
||||
return [[REFloatItem alloc] initWithTitle:title value:value];
|
||||
return [[self alloc] initWithTitle:title value:value];
|
||||
}
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(float)value sliderValueChangeHandler:(void(^)(REFloatItem *item))sliderValueChangeHandler
|
||||
{
|
||||
return [[REFloatItem alloc] initWithTitle:title value:value sliderValueChangeHandler:sliderValueChangeHandler];
|
||||
return [[self alloc] initWithTitle:title value:value sliderValueChangeHandler:sliderValueChangeHandler];
|
||||
}
|
||||
|
||||
- (id)initWithTitle:(NSString *)title value:(float)value
|
||||
|
||||
15
RETableViewManager/Items/RELongTextItem.h
Normal file
15
RETableViewManager/Items/RELongTextItem.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// RELongTextItem.h
|
||||
// RETableViewManagerExample
|
||||
//
|
||||
// Created by Roman Efimov on 4/11/13.
|
||||
// Copyright (c) 2013 Roman Efimov. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RETextItem.h"
|
||||
|
||||
@interface RELongTextItem : RETextItem
|
||||
|
||||
+ (id)itemWithValue:(NSString *)value placeholder:(NSString *)placeholder;
|
||||
|
||||
@end
|
||||
18
RETableViewManager/Items/RELongTextItem.m
Normal file
18
RETableViewManager/Items/RELongTextItem.m
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// RELongTextItem.m
|
||||
// RETableViewManagerExample
|
||||
//
|
||||
// Created by Roman Efimov on 4/11/13.
|
||||
// Copyright (c) 2013 Roman Efimov. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RELongTextItem.h"
|
||||
|
||||
@implementation RELongTextItem
|
||||
|
||||
+ (id)itemWithValue:(NSString *)value placeholder:(NSString *)placeholder
|
||||
{
|
||||
return [[self alloc] initWithTitle:@"" value:value placeholder:placeholder];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(NSString *)value selectionHandler:(void(^)(RERadioItem *item))selectionHandler
|
||||
{
|
||||
return [[RERadioItem alloc] initWithTitle:title value:value selectionHandler:selectionHandler];
|
||||
return [[self alloc] initWithTitle:title value:value selectionHandler:selectionHandler];
|
||||
}
|
||||
|
||||
- (id)initWithTitle:(NSString *)title value:(NSString *)value selectionHandler:(void(^)(RERadioItem *item))selectionHandler
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(NSString *)value
|
||||
{
|
||||
return [[RETextItem alloc] initWithTitle:title value:value];
|
||||
return [[self alloc] initWithTitle:title value:value];
|
||||
}
|
||||
|
||||
+ (id)itemWithTitle:(NSString *)title value:(NSString *)value placeholder:(NSString *)placeholder
|
||||
{
|
||||
return [[RETextItem alloc] initWithTitle:title value:value placeholder:placeholder];
|
||||
return [[self alloc] initWithTitle:title value:value placeholder:placeholder];
|
||||
}
|
||||
|
||||
- (id)initWithTitle:(NSString *)title value:(NSString *)value
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#import "REBoolItem.h"
|
||||
#import "RERadioItem.h"
|
||||
#import "RETextItem.h"
|
||||
#import "RELongTextItem.h"
|
||||
#import "RENumberItem.h"
|
||||
#import "RECreditCardItem.h"
|
||||
#import "REFloatItem.h"
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
[self mapObjectClass:@"RERadioItem" toTableViewCellClass:@"RETableViewCell"];
|
||||
[self mapObjectClass:@"REBoolItem" toTableViewCellClass:@"RETableViewBoolCell"];
|
||||
[self mapObjectClass:@"RETextItem" toTableViewCellClass:@"RETableViewTextCell"];
|
||||
[self mapObjectClass:@"RELongTextItem" toTableViewCellClass:@"RETableViewLongTextCell"];
|
||||
[self mapObjectClass:@"RENumberItem" toTableViewCellClass:@"RETableViewNumberCell"];
|
||||
[self mapObjectClass:@"REFloatItem" toTableViewCellClass:@"RETableViewFloatCell"];
|
||||
[self mapObjectClass:@"REDateTimeItem" toTableViewCellClass:@"RETableViewDateTimeCell"];
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
300E5A29170F48EC00910013 /* RETableViewFloatCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 300E5A28170F48EC00910013 /* RETableViewFloatCell.m */; };
|
||||
300E5A2C170F621400910013 /* REDateTimeItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 300E5A2B170F621400910013 /* REDateTimeItem.m */; };
|
||||
300E5A2F170F63B600910013 /* RETableViewDateTimeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 300E5A2E170F63B600910013 /* RETableViewDateTimeCell.m */; };
|
||||
300E5B3F17170AE100910013 /* RELongTextItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 300E5B3E17170AE100910013 /* RELongTextItem.m */; };
|
||||
300E5B4217170B0200910013 /* RETableViewLongTextCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 300E5B4117170B0100910013 /* RETableViewLongTextCell.m */; };
|
||||
302D2150170B25B10085654F /* ControlsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D214A170B25B10085654F /* ControlsViewController.m */; };
|
||||
302D2151170B25B10085654F /* ListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D214C170B25B10085654F /* ListViewController.m */; };
|
||||
302D2152170B25B10085654F /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D214E170B25B10085654F /* RootViewController.m */; };
|
||||
@@ -55,6 +57,10 @@
|
||||
300E5A2B170F621400910013 /* REDateTimeItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = REDateTimeItem.m; sourceTree = "<group>"; };
|
||||
300E5A2D170F63B600910013 /* RETableViewDateTimeCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RETableViewDateTimeCell.h; sourceTree = "<group>"; };
|
||||
300E5A2E170F63B600910013 /* RETableViewDateTimeCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RETableViewDateTimeCell.m; sourceTree = "<group>"; };
|
||||
300E5B3D17170AE000910013 /* RELongTextItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RELongTextItem.h; sourceTree = "<group>"; };
|
||||
300E5B3E17170AE100910013 /* RELongTextItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RELongTextItem.m; sourceTree = "<group>"; };
|
||||
300E5B4017170B0100910013 /* RETableViewLongTextCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RETableViewLongTextCell.h; sourceTree = "<group>"; };
|
||||
300E5B4117170B0100910013 /* RETableViewLongTextCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RETableViewLongTextCell.m; sourceTree = "<group>"; };
|
||||
302D2149170B25B10085654F /* ControlsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ControlsViewController.h; sourceTree = "<group>"; };
|
||||
302D214A170B25B10085654F /* ControlsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ControlsViewController.m; sourceTree = "<group>"; };
|
||||
302D214B170B25B10085654F /* ListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListViewController.h; sourceTree = "<group>"; };
|
||||
@@ -215,6 +221,8 @@
|
||||
300E5A28170F48EC00910013 /* RETableViewFloatCell.m */,
|
||||
300E5A2D170F63B600910013 /* RETableViewDateTimeCell.h */,
|
||||
300E5A2E170F63B600910013 /* RETableViewDateTimeCell.m */,
|
||||
300E5B4017170B0100910013 /* RETableViewLongTextCell.h */,
|
||||
300E5B4117170B0100910013 /* RETableViewLongTextCell.m */,
|
||||
);
|
||||
path = Cells;
|
||||
sourceTree = "<group>";
|
||||
@@ -236,6 +244,8 @@
|
||||
300E5A25170F486800910013 /* REFloatItem.m */,
|
||||
300E5A2A170F621400910013 /* REDateTimeItem.h */,
|
||||
300E5A2B170F621400910013 /* REDateTimeItem.m */,
|
||||
300E5B3D17170AE000910013 /* RELongTextItem.h */,
|
||||
300E5B3E17170AE100910013 /* RELongTextItem.m */,
|
||||
);
|
||||
path = Items;
|
||||
sourceTree = "<group>";
|
||||
@@ -407,6 +417,8 @@
|
||||
300E5A29170F48EC00910013 /* RETableViewFloatCell.m in Sources */,
|
||||
300E5A2C170F621400910013 /* REDateTimeItem.m in Sources */,
|
||||
300E5A2F170F63B600910013 /* RETableViewDateTimeCell.m in Sources */,
|
||||
300E5B3F17170AE100910013 /* RELongTextItem.m in Sources */,
|
||||
300E5B4217170B0200910013 /* RETableViewLongTextCell.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
[weakSelf.tableView deselectRowAtIndexPath:item.indexPath animated:YES];
|
||||
[weakSelf.navigationController pushViewController:[[ListViewController alloc] initWithStyle:UITableViewStylePlain] animated:YES];
|
||||
}]];
|
||||
|
||||
[section addItem:[RELongTextItem itemWithTitle:@"" value:@""]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user