Commit 3a2738ae authored by admin's avatar admin

修复键盘遮住文本框

parent 2b324a30
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
NSString *url = [NSString stringWithFormat:@"%@%@%@?read=%@&page_number=%d&page_size=%d", kRedStarURL, kAnnounceListURL ,user_uuid ,_stateStr, page_number, page_size]; NSString *url = [NSString stringWithFormat:@"%@%@%@?read=%@&page_number=%d&page_size=%d", kRedStarURL, kAnnounceListURL ,user_uuid ,_stateStr, page_number, page_size];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient getAnnounceListWithCompletion:^(id response, NSError *error) { [httpClient getAnnounceListWithCompletion:^(id response, NSError *error) {
NSLog(@"公告response = %@", response);
if (response[@"success"]) { if (response[@"success"]) {
NSDictionary *dict = response[@"data"]; NSDictionary *dict = response[@"data"];
NSArray *array = dict[@"records"]; NSArray *array = dict[@"records"];
...@@ -135,10 +136,11 @@ ...@@ -135,10 +136,11 @@
} }
NSLog(@"url ==== %@", url);
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[httpClient getAnnounceListWithCompletion:^(id response, NSError *error) { [httpClient getAnnounceListWithCompletion:^(id response, NSError *error) {
NSLog(@"segemnt 公告 = %@ error = %@", response, error);
if (response[@"success"]) { if (response[@"success"]) {
NSDictionary *dict = response[@"data"]; NSDictionary *dict = response[@"data"];
NSArray *array = dict[@"records"]; NSArray *array = dict[@"records"];
......
...@@ -77,6 +77,8 @@ ...@@ -77,6 +77,8 @@
return YES; return YES;
} }
#pragma mark - lazy loading #pragma mark - lazy loading
- (UILabel *)titleLabel - (UILabel *)titleLabel
{ {
......
...@@ -17,5 +17,8 @@ ...@@ -17,5 +17,8 @@
@property (nonatomic, strong) TakePhotoView *takePhotoView; @property (nonatomic, strong) TakePhotoView *takePhotoView;
@property (nonatomic, strong) UIButton *reportBtn; @property (nonatomic, strong) UIButton *reportBtn;
@property (nonatomic, strong) UILabel *placeholderLabel1;
@property (nonatomic, strong) UILabel *placeholderLabel2;
@end @end
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
@interface AddQuestionFooterView () <UITextViewDelegate> @interface AddQuestionFooterView () <UITextViewDelegate>
@property (nonatomic, strong) UIImageView *backImageView1; @property (nonatomic, strong) UIImageView *backImageView1;
@property (nonatomic, strong) UILabel *placeholderLabel1;
@property (nonatomic, strong) UIImageView *backImageView2; @property (nonatomic, strong) UIImageView *backImageView2;
@property (nonatomic, strong) UILabel *placeholderLabel2;
@end @end
@implementation AddQuestionFooterView @implementation AddQuestionFooterView
...@@ -101,33 +99,6 @@ ...@@ -101,33 +99,6 @@
} }
#pragma mark - UITextView Delegate
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if (![text isEqualToString:@""]) {
if (textView.tag == 1001) {
_placeholderLabel1.hidden = YES;
} else {
_placeholderLabel2.hidden = YES;
}
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
if (textView.tag == 1001) {
_placeholderLabel1.hidden = NO;
} else {
_placeholderLabel2.hidden = NO;
}
}
if ([text isEqualToString:@"\n"]) {
[self.titleTextView resignFirstResponder];
[self.contentTextView resignFirstResponder];
return NO;
}
return YES;
}
#pragma mark - lazy loading #pragma mark - lazy loading
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define kAddQuestionCell @"UITableViewCellIdentifier" #define kAddQuestionCell @"UITableViewCellIdentifier"
@interface AddQuestionViewController () <UITableViewDelegate, UITableViewDataSource, TakePhotoViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate> @interface AddQuestionViewController () <UITableViewDelegate, UITableViewDataSource, TakePhotoViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate, UITextViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) AddQuestionFooterView *footerView; @property (nonatomic, strong) AddQuestionFooterView *footerView;
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
@property (nonatomic ,strong) UILabel *selectLabel; @property (nonatomic ,strong) UILabel *selectLabel;
@property (nonatomic ,strong) UILabel *selectLabel1; @property (nonatomic ,strong) UILabel *selectLabel1;
@end @end
@implementation AddQuestionViewController @implementation AddQuestionViewController
...@@ -415,6 +417,8 @@ ...@@ -415,6 +417,8 @@
} else { } else {
_footerView = [[AddQuestionFooterView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, (kScreenHeight - 100 - 64))]; _footerView = [[AddQuestionFooterView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, (kScreenHeight - 100 - 64))];
} }
_footerView.titleTextView.delegate = self;
_footerView.contentTextView.delegate = self;
} }
return _footerView; return _footerView;
} }
...@@ -423,14 +427,32 @@ ...@@ -423,14 +427,32 @@
[self.tableView endEditing:YES]; [self.tableView endEditing:YES];
} }
/* #pragma mark - UITextView Delegate
#pragma mark - Navigation - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if (![text isEqualToString:@""]) {
// In a storyboard-based application, you will often want to do a little preparation before navigation if (textView.tag == 1001) {
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { self.footerView.placeholderLabel1.hidden = YES;
// Get the new view controller using [segue destinationViewController]. } else {
// Pass the selected object to the new view controller. self.footerView.placeholderLabel2.hidden = YES;
}
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
if (textView.tag == 1001) {
self.footerView.placeholderLabel1.hidden = NO;
} else {
self.footerView.placeholderLabel2.hidden = NO;
}
}
if ([text isEqualToString:@"\n"]) {
[self.footerView.titleTextView resignFirstResponder];
[self.footerView.contentTextView resignFirstResponder];
return NO;
}
return YES;
} }
*/
@end @end
...@@ -136,6 +136,7 @@ ...@@ -136,6 +136,7 @@
_commentView.backgroundColor = [UIColor whiteColor]; _commentView.backgroundColor = [UIColor whiteColor];
} }
_commentView.contentTextView.text = @""; _commentView.contentTextView.text = @"";
_commentView.contentTextView.delegate = self;
[_commentView.quitBtn addTarget:self action:@selector(closeBackGroundView) forControlEvents:UIControlEventTouchUpInside]; [_commentView.quitBtn addTarget:self action:@selector(closeBackGroundView) forControlEvents:UIControlEventTouchUpInside];
[_commentView.sureBtn addTarget:self action:@selector(submitComment:) forControlEvents:UIControlEventTouchUpInside]; [_commentView.sureBtn addTarget:self action:@selector(submitComment:) forControlEvents:UIControlEventTouchUpInside];
[self.view insertSubview:_backGroundView aboveSubview:_tableView]; [self.view insertSubview:_backGroundView aboveSubview:_tableView];
...@@ -160,6 +161,27 @@ ...@@ -160,6 +161,27 @@
} }
- (void)textViewDidBeginEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight - 173, kScreenWidth, kCommentViewHeight);
}];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight, kScreenWidth, kCommentViewHeight);
}];
}
//-(void)textFieldDidBeginEditing:(UITextField *)textField
//{
//
//}
// 提交评论 // 提交评论
- (void)submitComment:(UIButton *)sender - (void)submitComment:(UIButton *)sender
{ {
......
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
@property (nonatomic, strong) TakePhotoView *takePhotoView; @property (nonatomic, strong) TakePhotoView *takePhotoView;
@property (nonatomic, strong) UIButton *reportBtn; @property (nonatomic, strong) UIButton *reportBtn;
@property (nonatomic, strong) UITextView *contentTextView; @property (nonatomic, strong) UITextView *contentTextView;
@property (nonatomic, strong) UILabel *placeholderLabel2;
@end @end
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
@property (nonatomic, strong) UILabel *pictureLabel; @property (nonatomic, strong) UILabel *pictureLabel;
@property (nonatomic, strong) UILabel *introLabel; @property (nonatomic, strong) UILabel *introLabel;
@property (nonatomic, strong) UIImageView *backImageView2; @property (nonatomic, strong) UIImageView *backImageView2;
@property (nonatomic, strong) UILabel *placeholderLabel2;
@end @end
@implementation InspectDetailFooterView @implementation InspectDetailFooterView
...@@ -81,22 +81,7 @@ ...@@ -81,22 +81,7 @@
} }
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if (![text isEqualToString:@""]) {
_placeholderLabel2.hidden = YES;
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
_placeholderLabel2.hidden = NO;
}
if ([text isEqualToString:@"\n"]) {
[self.contentTextView resignFirstResponder];
return NO;
}
return YES;
}
- (UILabel *)pictureLabel - (UILabel *)pictureLabel
{ {
...@@ -172,7 +157,6 @@ ...@@ -172,7 +157,6 @@
if (!_contentTextView) { if (!_contentTextView) {
_contentTextView = [[UITextView alloc] init]; _contentTextView = [[UITextView alloc] init];
_contentTextView.font = [UIFont systemFontOfSize:15.0]; _contentTextView.font = [UIFont systemFontOfSize:15.0];
_contentTextView.delegate = self;
_contentTextView.translatesAutoresizingMaskIntoConstraints = NO; _contentTextView.translatesAutoresizingMaskIntoConstraints = NO;
[self.backImageView2 addSubview:_contentTextView]; [self.backImageView2 addSubview:_contentTextView];
......
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
#define kInspectNotUploadCell @"InspectNotUploadCell" #define kInspectNotUploadCell @"InspectNotUploadCell"
@interface InspectNotUploadViewController () <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate , TakePhotoViewDelegate, UIScrollViewDelegate, UIAlertViewDelegate> @interface InspectNotUploadViewController () <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate , TakePhotoViewDelegate, UIScrollViewDelegate, UIAlertViewDelegate, UITextViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) InspectDetailFooterView *footerView; @property (nonatomic, strong) InspectDetailFooterView *footerView;
@property (nonatomic, strong) NSMutableArray *imageNameArray; @property (nonatomic, strong) NSMutableArray *imageNameArray;
@property (nonatomic, strong) NSLayoutConstraint *tableBottom;
@property (nonatomic, strong) NSLayoutConstraint *tableTop;
@end @end
...@@ -311,8 +312,8 @@ ...@@ -311,8 +312,8 @@
_tableView.estimatedRowHeight = 300.0; _tableView.estimatedRowHeight = 300.0;
[self.view addSubview:_tableView]; [self.view addSubview:_tableView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; self.tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop]; [self.view addConstraint:_tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft]; [self.view addConstraint:tableLeft];
...@@ -320,8 +321,8 @@ ...@@ -320,8 +321,8 @@
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight]; [self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; self.tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom]; [self.view addConstraint:_tableBottom];
} }
return _tableView; return _tableView;
} }
...@@ -330,6 +331,7 @@ ...@@ -330,6 +331,7 @@
{ {
if (!_footerView) { if (!_footerView) {
_footerView = [[InspectDetailFooterView alloc] init]; _footerView = [[InspectDetailFooterView alloc] init];
_footerView.contentTextView.delegate = self;
} }
return _footerView; return _footerView;
} }
...@@ -340,6 +342,42 @@ ...@@ -340,6 +342,42 @@
[self.footerView.contentTextView resignFirstResponder]; [self.footerView.contentTextView resignFirstResponder];
} }
} }
- (void)textViewDidBeginEditing:(UITextView *)textView
{
self.tableTop.constant = -216;
self.tableBottom.constant = -216;
[UIView animateWithDuration:0.3 animations:^{
[self.tableView layoutIfNeeded];
}];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
self.tableTop.constant = 0;
self.tableBottom.constant = 0;
[UIView animateWithDuration:0.3 animations:^{
[self.tableView layoutIfNeeded];
}];
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if (![text isEqualToString:@""]) {
self.footerView.placeholderLabel2.hidden = YES;
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
self.footerView.placeholderLabel2.hidden = NO;
}
if ([text isEqualToString:@"\n"]) {
[self.footerView.contentTextView resignFirstResponder];
return NO;
}
return YES;
}
/* /*
#pragma mark - Navigation #pragma mark - Navigation
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define kRankDetailCell @"RankDetailTableCell" #define kRankDetailCell @"RankDetailTableCell"
@interface RankDetailViewController () <UITableViewDataSource, UITableViewDelegate, RankHeadViewDelegate> @interface RankDetailViewController () <UITableViewDataSource, UITableViewDelegate, RankHeadViewDelegate, UITextViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) RankDetailHeaderView *rankDetailHeaderView; @property (nonatomic, strong) RankDetailHeaderView *rankDetailHeaderView;
...@@ -89,6 +89,8 @@ ...@@ -89,6 +89,8 @@
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
#pragma mark - Private Methods #pragma mark - Private Methods
- (void)requestRankingDetail - (void)requestRankingDetail
...@@ -136,6 +138,7 @@ ...@@ -136,6 +138,7 @@
_commentView.backgroundColor = [UIColor whiteColor]; _commentView.backgroundColor = [UIColor whiteColor];
} }
_commentView.contentTextView.text = @""; _commentView.contentTextView.text = @"";
_commentView.contentTextView.delegate = self;
[_commentView.quitBtn addTarget:self action:@selector(closeBackGroundView) forControlEvents:UIControlEventTouchUpInside]; [_commentView.quitBtn addTarget:self action:@selector(closeBackGroundView) forControlEvents:UIControlEventTouchUpInside];
[_commentView.sureBtn addTarget:self action:@selector(submitComment:) forControlEvents:UIControlEventTouchUpInside]; [_commentView.sureBtn addTarget:self action:@selector(submitComment:) forControlEvents:UIControlEventTouchUpInside];
[self.view insertSubview:_backGroundView aboveSubview:_tableView]; [self.view insertSubview:_backGroundView aboveSubview:_tableView];
...@@ -160,6 +163,20 @@ ...@@ -160,6 +163,20 @@
} }
- (void)textViewDidBeginEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight - 173, kScreenWidth, kCommentViewHeight);
}];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
[UIView animateWithDuration:0.3 animations:^{
_commentView.frame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight, kScreenWidth, kCommentViewHeight);
}];
}
// 提交评论 // 提交评论
- (void)submitComment:(UIButton *)sender - (void)submitComment:(UIButton *)sender
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment