我的商铺项目总结

来源:互联网 发布:没有性格特点知乎 编辑:程序博客网 时间:2024/05/16 01:01

1.

#pragma mark - 键盘通知的处理

//添加键盘通知响应

- (void)viewDidAppear:(BOOL)animated{

    [super viewDidAppear:animated];

    [[NSNotificationCenter defaultCenter]addObserver:selfselector:@selector(handleKeyboardWillShow:)name:UIKeyboardWillShowNotificationobject:nil];

    [[NSNotificationCenter defaultCenter]addObserver:selfselector:@selector(handleKeyboardWillHide:)name:UIKeyboardWillHideNotificationobject:nil];

}

//移除通知观察者

- (void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];

    [[NSNotificationCenterdefaultCenter]removeObserver:self];

}

- (void)handleKeyboardWillShow:(NSNotification *)paramNotification{

    //获取键盘通知的属性

    NSDictionary *userInfo = [paramNotificationuserInfo];

    NSNumber *animationCurveObject = [userInfovalueForKey:UIKeyboardAnimationCurveUserInfoKey];

    NSNumber *animationDurationObject = [userInfovalueForKey:UIKeyboardAnimationDurationUserInfoKey];

    NSValue *keyboardEndRectObject = [userInfovalueForKey:UIKeyboardFrameEndUserInfoKey];

    NSUInteger animationCurve = [animationCurveObjectintegerValue];

    double animationDuration = [animationDurationObjectdoubleValue];

    CGRect keyboardEndRect = [keyboardEndRectObjectCGRectValue];

    //开始一个动画,修改popView的位置

    [UIViewbeginAnimations:@"changePopViewFrame"context:nil];

    [UIView setAnimationDuration:animationDuration];

    [UIView setAnimationCurve:(UIViewAnimationCurve)animationCurve];

    //获得两个frame之间的交集

    UIView *popView = [self.view.superviewviewWithTag:PopViewTag];

    CGRect intersectionOfKeyboardRectAndPopViewRect =CGRectIntersection(popView.frame, keyboardEndRect);

    CGFloat intersectionHeight = intersectionOfKeyboardRectAndPopViewRect.size.height;

    //NSLog(@"%f",intersectionHeight);

    //只移动intersectionHeight只是让view与键盘之间没有缝隙

    rect = popView.frame;

    CGFloat moveHeight = [AppHelperratelyCaculateHeight:MoveYOffset];

    popView.frame = CGRectMake(rect.origin.x,rect.origin.y - intersectionHeight - moveHeight,rect.size.width,rect.size.height);

    [UIViewcommitAnimations];

}


2.

#pragma mark - 判断字符串为空和只为空格

+ (BOOL)isBlankString:(NSString *)testString{

    if (testString == nil) {

        return YES;

    }

    if (testString == NULL) {

        return YES;

    }

    if ([testString isKindOfClass:[NSNull class]]) {

        return YES;

    }

    if ([testString length] == 0) {

        return YES;

    }

    return NO;

}

3.

-(UIImage*) OriginImage:(UIImage *)image scaleToSize:(CGSize)size

{

    UIGraphicsBeginImageContext(size); //size CGSize类型,即你所需要的图片尺寸

    

    [image drawInRect:CGRectMake(0,0, size.width, size.height)];

    

    UIImage* scaledImage =UIGraphicsGetImageFromCurrentImageContext();

    

    UIGraphicsEndImageContext();

    

    return scaledImage;   //返回的就是已经改变的图片

}

4.
soap :

//修改我的店铺密码

#define ModifyMyShopPassWord(shopMobile,shopOldPassword,shopNewPassword)    [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"><soap12:Body><ModifyPassword xmlns=\"http://123.233.116.125/\"><mobile>%@</mobile><oldPassWord>%@</oldPassWord><newPassWord>%@</newPassWord></ModifyPassword></soap12:Body></soap12:Envelope>",shopMobile,shopOldPassword,shopNewPassword]


- (void)modifyMyShopPasswordWithOldPassword:(NSString *)oldPassword andNewPassword:(NSString *)newPassword andPhoneNumber:(NSString *)phoneNumber{

    @autoreleasepool {

        if ([[NetworkMonitorsharedTheNetworkMonitor]isTheNetworkAvailable] ==NO) {

            [self stop];

            return;

        }

        //------------------------

        Merchant *theMerchant       = [CoreDataHelpersharedCoreDataHelper].nowMerchant;

        NSManagedObjectID *objectID = theMerchant.objectID;

        if (objectID) {

            

            theMerchant = (Merchant*)[operationContextobjectWithID:objectID];

        }

        else{

            [self stop];

            return;

        }

        NSLog(@"theMerchant.phone = %@",phoneNumber);

        //------------------------

        //根据原密码 ,手机号,新密码 修改密码

        NSString *soapMessage = ModifyMyShopPassWord(phoneNumber, oldPassword, newPassword);

        NSURL *url = [NSURLURLWithString:kShopServiceURL];

        NSMutableURLRequest *request = [NSMutableURLRequestrequestWithURL:url];

        

        [request setHTTPMethod:@"POST"];

        [request addValue:@"application/soap+xml; charset = utf-8" forHTTPHeaderField:@"Content-Type"];

        [request addValue: [NSStringstringWithFormat:@"%@",@([soapMessagelength])]forHTTPHeaderField:@"Content-Length"];

        [request addValue:@"ModifyPassword" forHTTPHeaderField:@"SOAPAction"];

        [request setHTTPBody: [soapMessagedataUsingEncoding:NSUTF8StringEncoding]];

        //--------------------------

        [request setTimeoutInterval:kTimeoutInterval];

        [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];

        [request setHTTPShouldHandleCookies:NO];

        

        [NSURLConnectionsendAsynchronousRequest:request

                                           queue:[NSOperationQueuenew]

                               completionHandler:^(NSURLResponse *response,NSData *data, NSError *connectionError) {

                                   

                          if (connectionError || data.length <1) {

                                       

                                 FShowObjectInfo(@" connectionError", connectionError);

                                 FShowObjectInfo(@" data           ", data);

                                       

                                 [self stop];

                                 return;

                                       

                           }

                                   

                           NSString *string = [[NSStringalloc]initWithData: data encoding:NSUTF8StringEncoding];

                                   

                           if (string) {

                      NSString *resultStr = [AppHelpergetValueForKey:@"ModifyPasswordResult" 

  fromXmlString:string];

                                       //NSLog(@"resultStr = %@",resultStr);

                                       dispatch_queue_t mainQueue =dispatch_get_main_queue();

                                       if ([resultStrintegerValue] == 0) {

                                           //成功

                                           dispatch_sync(mainQueue, ^{

                                               [self.observerdoSomethingOfDelegateObjectWithBool:YES];

                                           });

                                       }else{

                                           dispatch_sync(mainQueue, ^{

                                               [self.observerdoSomethingOfDelegateObjectWithBool:NO];

                                           });

                                       }

                                   }

                               }];

    }

}




0 0
原创粉丝点击