#pragma mark 顶部当行条的创建
-(void)createHeadView
{
UIView *navBar=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44+[UIApplication sharedApplication].statusBarFrame.size.height)];
navBar.backgroundColor=kheader;
[self.view addSubview:navBar];
UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(0,[UIApplication sharedApplication].statusBarFrame.size.height, self.view.frame.size.width, 44)];
lab.text=@"发布心情";
lab.font=f20Font;
lab.textColor = kWhite;
lab.textAlignment=NSTextAlignmentCenter;
[self.view addSubview:lab];
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
leftBtn.frame = CGRectMake(0, [UIApplication sharedApplication].statusBarFrame.size.height, 80, 40);
[leftBtn setBackgroundImage:[UIImage imageNamed:@"返回键透明.png"] forState:UIControlStateNormal];
[leftBtn setBackgroundImage:[UIImage imageNamed:@"返回键-按下.png"] forState:UIControlStateHighlighted];
[leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[leftBtn addTarget:self action:@selector(leftBtnClick) forControlEvents:UIControlEventTouchUpInside];
[navBar addSubview:leftBtn];
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
rightBtn.frame = CGRectMake(self.view.frame.size.width-60-10, [UIApplication sharedApplication].statusBarFrame.size.height+10, 60, 24);
[rightBtn setBackgroundImage:[UIImage imageNamed:@"发布.png"] forState:UIControlStateNormal];
[rightBtn setBackgroundImage:[UIImage imageNamed:@"发布-选.png"] forState:UIControlStateHighlighted];
[rightBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
[navBar addSubview:rightBtn];
self.view.backgroundColor = k21;
}
-(void)sendReqAsync:(int) currentPage
{
loading = [[LoadingView alloc]initWithFrame:CGRectMake(100, 64, 100, 100)];
[loading loadingWithTrips:@"发布中···"];
[self.view addSubview:loading];
NSString *urlStr=[NSString stringWithFormat:myDogMoodAddUrl ,[AppDelegate instance].memberID_USER,self.feeling.text];
urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:urlStr];
__weak ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
//[request setDelegate:self];
[request setRequestMethod:@"GET"];
[request startAsynchronous];
[request setCompletionBlock:^{
NSData *responseData = [request responseData];
NSMutableDictionary * mdic =[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:Nil];
// NSMutableArray * marr=[mdic objectForKey:BODYREASON];
if ([[mdic objectForKey:CODEREASON]isEqualToString:success100]||[[mdic objectForKey:CODEREASON]isEqualToString:maxLimit]) {
[loading loadingSuccess];
// CircleOfFirends1ViewController * page=(CircleOfFirends1ViewController *) [self.navigationController.viewControllers objectAtIndex: ([self.navigationController.viewControllers count] -1)];
// [self.navigationController popViewControllerAnimated:YES];
[[NSNotificationCenter defaultCenter]postNotificationName:INTEGRAL_NUM_NOTIFY object:self];
[[NSNotificationCenter defaultCenter]postNotificationName:BACK_HOME_PAGE_SUBVIEW1_NOTIFY object:self];//返回到主页中的子页面1
// [self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: ([self.navigationController.viewControllers count] -2)] animated:YES];
// [[NSNotificationCenter defaultCenter]postNotificationName:PHOTO_DIARY_FEELING_BACK_NOTIFY object:self];
// [self dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popViewControllerAnimated:YES];
}
}];
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"%s,%@",__FUNCTION__, error);
[loading loadingFailed];
}];
}
//消息提示
[SGInfoAlert showInfo:@" \n最大字数不能超过150\n "
bgColor: [UIColor orangeColor].CGColor
inView:self.view
vertical:0.3];
-(BOOL) isEmpty:(NSString *) str {
if (!str) {
return YES;
} else {
//A character set containing only the whitespace characters space (U+0020) and tab (U+0009) and the newline and nextline characters (U+000A–U+000D, U+0085).
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
//Returns a new string made by removing from both ends of the receiver characters contained in a given character set.
NSString *trimedString = [str stringByTrimmingCharactersInSet:set];
if ([trimedString length] == 0) {
return YES;
} else {
return NO;
}
}
}
-(BOOL) isEmpty:(NSString *) str {
if (!str) {
return YES;
} else {
//A character set containing only the whitespace characters space (U+0020) and tab (U+0009) and the newline and nextline characters (U+000A–U+000D, U+0085).
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
//Returns a new string made by removing from both ends of the receiver characters contained in a given character set.
NSString *trimedString = [str stringByTrimmingCharactersInSet:set];
if ([trimedString length] == 0) {
return YES;
} else {
return NO;
}
}
}