首页 > 其他 > 详细

【代码笔记】点评内容

时间:2016-01-21 10:18:53      阅读:245      评论:0      收藏:0      [点我收藏+]

一,效果图。

技术分享

二,工程图。

技术分享

三,代码。

ViewController.h

技术分享
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UITextViewDelegate>
{
    //评论内容
    UITextView *commentTextView;
}

@end
技术分享

 

ViewController.m

技术分享
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //初始化点评内容
    [self addCommentView];
    
}
#pragma -mark -functions
//初始化点评内容
-(void)addCommentView
{
    //点评内容
    commentTextView=[[UITextView alloc]initWithFrame:CGRectMake(50, 180, 300, 90)];
    commentTextView.text=@"亲,您对商户感觉如何,环境怎样,服务态度如何。(500字符内)";
    commentTextView.font=[UIFont systemFontOfSize:14];
    commentTextView.backgroundColor=[UIColor redColor];
    commentTextView.delegate=self;
    [self.view addSubview:commentTextView];

}
#pragma mark - UITextView Delegate Methods

-(BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    if ([textView.text isEqualToString:@"亲,您对商户感觉如何,环境怎样,服务态度如何。(500字符内)"]) {
        textView.text=@"";
    }
    return YES;
}
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
技术分享

 

【代码笔记】点评内容

原文:http://www.cnblogs.com/yang-guang-girl/p/5147176.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!