花色中大家可能会蒙受,在订单完结后评价的分界面,以及刮奖的分界面,笔者归纳的说一下作者的达成情势,效果如下:

// 1.创办工程 -> 选 Next.

1、

此方法会在所在cell滑出显示屏外的时候崩溃报错

 StoreConLabTableViewCell *endTCell = [self.tableView cellForRowAtIndex
Path:[NSIndexPath indexPathForRow:4 inSection:1]];

yzc579亚洲城官网 1五星好评以及刮奖.gif

yzc579亚洲城官网 2

2、

东拼西凑70%这种加百分号字符串的时候 用 %% 那样三个%%来表示%。

率先先说说五星好评分界面:1、先说一下思路

QQ20160722-0.png

3、

为了不让弹出键盘挡住输入框。一般

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField.tag == 888) {
  [UIView animateWithDuration:0.26 animations:^{
            self.view.frame=CGRectMake(0, -50, WIDTH, HEIGHT);
        }];
    }    

在如上格局中上移分界面,合营使用下边代理方法使复苏

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField.tag==12) {
        [UIView animateWithDuration:0.26 animations:^{
            self.view.frame=CGRectMake(0, 0, WIDTH, HEIGHT);
        }];
    }
}

突发性分界面是tableView的时候也可在地点第二个代理方法中使tableView滚动到相应地点

  [UIView animateWithDuration:0.26 animations:^{
            [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:1 animated:YES];
        }];//这里可以不用考虑恢复,tableview可以人为滚动回来

此处须要注意的无法忘记<UITextFieldDelegate>,并且给需上移分界面包车型地铁textField标志tag,並且写上textField.delegate = self

yzc579亚洲城官网 395838E80-57A8-453A-8AEB-85332D1F620F.png那事实上正是五张图片,通过监听手指运动的职分,来开展图纸的转移首要正是八个措施- touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;//手指开始点击``- touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;//手指开始移动``- touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event;//手指离开2、实现

// 2.在Main.storyboard中放两张imageView,
先放撕掉后的,再在地点放撕掉前的,并开垦顾客交互,做好约束,然后将撕掉前的拽成属性.

4、

能够透过给textField绑定方法,依据后边UIControl伊芙nt..不一样来促成不一样格局,如:

[textfield addTarget:self action:@selector(change:) forControlEvents:
UIControlEventEditingChanged];

然后在中实时获得输入文本,textField多的话同样要求tag标识

-(void)change:(UITextField*)textField{
  NSString *str = textField.text

}
//手指开始点击,点击的位置判断是否添加星星- touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {UITouch *touch = [touches anyObject];CGPoint point = [touch locationInView:self];//判断点击的位置是否在视图上if (point.x >= self.firstStarImage.x && point.x <= (self.width) && (point.y > self.firstStarImage.y & point.y< self.height )) {//使用变量来判断是否添加星星 self.isAddStar = YES; }else { self.isAddStar = NO; }}//手指开始移动,在移动到的位置添加星星- touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {if(self.isAddStar){ UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; //添加星星 [self setStarForegroundViewWithPoint:point]; }}//添加星星计算分数- setStarForegroundViewWithPoint:point {//添加星星float score = 0;score += [self changeImg:point.x image:self.firstStarImage];score += [self changeImg:point.x image:self.secondStarImage];score += [self changeImg:point.x image:self.threeStarImage];score += [self changeImg:point.x image:self.fourStarImage];score += [self changeImg:point.x image:self.fiveStarImage];//最少得半个星星if (score == 0) { score = 0.5; if (!self.halfImageStr) { self.halfImageStr = @"StarSelectHalf"; } [self.firstStarImage setImage:[UIImage imageNamed:self.halfImageStr]]; }self.score = score;}//设置添加星星,返回分数-changeImg:x image:(UIImageView*)imgView{if (!self.normalStr) { self.normalStr = @"StarNormal";}if (!self.selectStr) { self.selectStr = @"StarSelected";}if (!self.halfImageStr) { self.halfImageStr = @"StarSelectHalf";}if(x > (imgView.x + imgView.width/2)){ imgView.image = [UIImage imageNamed:self.selectStr]; return 1;}else if(x > imgView.x){ imgView.image = [UIImage imageNamed:self.halfImageStr]; return 0.5;}else{ imgView.image = [UIImage imageNamed: self.normalStr]; return 0;}}//结束的时候,将是否添加星星变为NO;-touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {self.isAddStar = NO;}

yzc579亚洲城官网 4

5、

实现此cell四周间隙分界面

yzc579亚洲城官网 5

荧屏快速照相 2017-01-05 凌晨4.33.40.png

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
此行代码先去掉全部分界线

//圆角
self.layer.cornerRadius = 8;
 self.layer.masksToBounds = YES;

   //配合圆角使用(待了解,性能相关) 
    self.contentView.layer.shouldRasterize = YES;
    self.contentView.layer.rasterizationScale = [[UIScreen mainScreen] scale];

//间隙处理:写在cell中
- (void)setFrame:(CGRect)frame {

    static CGFloat const margin = 10;

    frame.size.width -= 2 * margin;
    frame.origin.x = margin;
    frame.size.height -= margin;
    frame.origin.y += margin;

    [super setFrame:frame];
}

3、主要代码就这一个了,整个自己也做了包装,就算须求的话能够去下边包车型大巴链接地址里下载。

QQ20160722-1.png

6、

百度地图集成成功后获得经纬度、城市称号、城市编码

//导入对应控制器
#import "AppDelegate.h"
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Map/BMKMapComponent.h>
#import <BaiduMapAPI_Location/BMKLocationComponent.h>

 BMKLocationService* _locService;//定位
 BMKOfflineMap * _offlineMap;//离线地图相关(用于获取城市编码)

//用于保存
 NSString *longitudeStr;//经度
 NSString *latitudeStr;//纬度
 NSString *localStr;//城市
 NSString *cityCode;//编码

在viewDidLoad中调用启动定位
- (void)startMap{
    _locService = [[BMKLocationService alloc]init];//定位功能的初始化
    _locService.delegate = self;//设置代理位self
    //启动LocationService
    [_locService startUserLocationService];//启动定位服务

    _offlineMap = [[BMKOfflineMap alloc] init];
}

- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation{

    BMKCoordinateRegion region;

    region.center.latitude  = userLocation.location.coordinate.latitude;
    region.center.longitude = userLocation.location.coordinate.longitude;
    region.span.latitudeDelta = 0;
    region.span.longitudeDelta = 0;
    NSLog(@"当前的坐标是:%f,%f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
//获取经纬度
    longitudeStr = [NSString stringWithFormat:@"%f",userLocation.location.coordinate.longitude];
    latitudeStr = [NSString stringWithFormat:@"%f",userLocation.location.coordinate.latitude];
   // ApplicationDelegate
    ApplicationDelegate.latitude = latitudeStr;
    ApplicationDelegate.longitude = longitudeStr;

    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder reverseGeocodeLocation: userLocation.location completionHandler:^(NSArray *array, NSError *error) {
        if (array.count > 0) {
            CLPlacemark *placemark = [array objectAtIndex:0];
            if (placemark != nil) {
                NSString *city = placemark.locality;

                NSLog(@"当前城市名称------%@",city);
                self.locationCityName.text = city;
                localStr = city;
                NSArray* records = [_offlineMap searchCity:city];
                BMKOLSearchRecord* oneRecord = [records objectAtIndex:0];
                //城市编码如:北京为131
                int cityId = oneRecord.cityID;//获取编码

                cityCode = [NSString stringWithFormat:@"%d",oneRecord.cityID];
                ApplicationDelegate.cityCode = cityCode;//全局保存地理

                [[XFBConfig Instance] saveCityCode:cityCode];
                if ([_offlineMap remove:cityId]) {


                }else{

                };
                [self loadHotStoreAndTuiJianStoreData];//根据定位加载商家

                [_locService stopUserLocationService];
            }
        }
    }];
}

帮衬咱们说一说刮奖的兑现。1、先说思路

//
3.在ViewController.m里按如下操作就可以兑现,撕美人衣裳(imageView)或然刮奖(label).

7、

存在底部标签栏调整器踏入没有标签栏调节器,来回切换错乱难点

- (void)pushToNextWithIdentiField:(NSString*)identi sender:(id)sender{
    self.hidesBottomBarWhenPushed = YES;//隐藏
    [self performSegueWithIdentifier:identi sender:sender];
    self.hidesBottomBarWhenPushed = NO;//必须要,否则回来时标签仍然消失
}
//在跟控制器面板中hidesBottomBarWhenPushed有时候需要取消勾选,有可能会影响
//整体界面偏移问题

没有导航看分界面步入有导航栏界面,一般在上个调节器viewWillAppear中写[self.navigationController setNavigationBarHidden:YES animated:animated];下一场再下个分界面在装置为no,
一般蒙受错乱难点 ,优先考虑动用 setNavigationBarHidden方法
并不是self.navigationController.navigationBarHidden =

yzc579亚洲城官网 6EAA2ED39-91A1-4764-B5DB-75C38AE644AC.png

//
//  ViewController.m
//  郭宝-午分享
//
//  Created by 郭宝 on 16/7/15.
//  Copyright © 2016年 郭宝. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageB;
@property (nonatomic,assign) BOOL isTouch;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

8、

经过地图移动 ,使大头针移到相应地方获取相应经纬度
一、先导入

#import <BaiduMapAPI_Base/BMKBaseComponent.h>//引入base相关所有的头文件
#import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
#import <BaiduMapAPI_Search/BMKSearchComponent.h>//引入检索功能所有的头文件
#import <BaiduMapAPI_Cloud/BMKCloudSearchComponent.h>//引入云检索功能所有的头文件
#import <BaiduMapAPI_Location/BMKLocationComponent.h>//引入定位功能所有的头文件
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>//引入计算工具所有的头文件
#import <BaiduMapAPI_Map/BMKMapView.h>//只引入所需的单个头文件

二、画图

yzc579亚洲城官网 7

荧屏快速照相 2017-01-05 凌晨5.29.48.png

此地注意,大头针button视图在mapView的上层,经纬度label视图跟mapView平级,在self.view上,

三、在 .m 中

@interface MapLocateViewController ()<BMKMapViewDelegate,BMKGeoCodeSearchDelegate,BMKLocationServiceDelegate>
{
    BMKGeoCodeSearch *_geoCodeSearch;    
    BMKReverseGeoCodeOption *_reverseGeoCodeOption;
    BMKLocationService *_locService;
}
@property (weak, nonatomic) IBOutlet BMKMapView *mapView;
@property (weak, nonatomic) IBOutlet UIButton *mapPin;//大头针
@property (weak, nonatomic) IBOutlet UILabel *longtitudeLab;//经度
@property (weak, nonatomic) IBOutlet UILabel *latitudeLab;//纬度
@end

@implementation MapLocateViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    [self initLocationService];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [_mapView viewWillAppear];
    _mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [_mapView viewWillDisappear];
    _mapView.delegate = nil; // 不用时,置nil
}

#pragma mark 初始化地图,定位
-(void)initLocationService
{

    [_mapView setMapType:BMKMapTypeStandard];// 地图类型 ->卫星/标准、

    _mapView.zoomLevel=17;
    _mapView.delegate=self;
    _mapView.showsUserLocation = YES;

    [_mapView bringSubviewToFront:_mapPin];


    if (_locService==nil) {

        _locService = [[BMKLocationService alloc]init];
        [_locService setDesiredAccuracy:kCLLocationAccuracyBest];
    }

    _locService.delegate = self;
    [_locService startUserLocationService];


    _mapView.showsUserLocation = NO;//先关闭显示的定位图层
    _mapView.userTrackingMode = BMKUserTrackingModeFollow;//设置定位的状态
    _mapView.showsUserLocation = YES;//显示定位图层
}

#pragma mark BMKLocationServiceDelegate
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
    _mapView.showsUserLocation = YES;//显示定位图层
    //设置地图中心为用户经纬度
    [_mapView updateLocationData:userLocation];

    BMKCoordinateRegion region ;//表示范围的结构体
    region.center = _mapView.centerCoordinate;//中心点
    region.span.latitudeDelta = 0.004;//经度范围(设置为0.1表示显示范围为0.2的纬度范围)
    region.span.longitudeDelta = 0.004;//纬度范围

    [_mapView setRegion:region animated:YES];
}

#pragma mark BMKMapViewDelegate
- (void)mapView:(BMKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
    //屏幕坐标转地图经纬度
    CLLocationCoordinate2D MapCoordinate=[_mapView convertPoint:_mapPin.center toCoordinateFromView:_mapView];

    //获取经纬度
    self.latitudeLab.text = [NSString stringWithFormat:@"%f",MapCoordinate.latitude];
    self.longtitudeLab.text = [NSString stringWithFormat:@"%f",MapCoordinate.longitude];

    if (_geoCodeSearch==nil) {
        //初始化地理编码类
        _geoCodeSearch = [[BMKGeoCodeSearch alloc]init];
        _geoCodeSearch.delegate = self;

    }
    if (_reverseGeoCodeOption==nil) {
        //初始化反地理编码类
        _reverseGeoCodeOption= [[BMKReverseGeoCodeOption alloc] init];
    }
        //需要逆地理编码的坐标位置
    _reverseGeoCodeOption.reverseGeoPoint =MapCoordinate;
    [_geoCodeSearch reverseGeoCode:_reverseGeoCodeOption];
}

//此方法可获取周边信息
#pragma mark BMKGeoCodeSearchDelegate
-(void) onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
    //获取周边用户信息
    if (error==BMK_SEARCH_NO_ERROR) {

      //  [self.cityDataArr removeAllObjects];
        for(BMKPoiInfo *poiInfo in result.poiList)
        {    

//用自定义一个model来接受信息
           // cityModel *model=[[cityModel alloc]init];
          //   model.name=poiInfo.name;
         //    model.address=poiInfo.address;
         //   CLLocationCoordinate2D _pt

           //用列表来展示获取的信息 
          //  [self.cityDataArr addObject:model];
           // [self.cityTableview reloadData];
        }
    }else{   
        NSLog(@"BMKSearchErrorCode: %u",error);
    }
}

首要正是两张图纸和多个label,刮开遮盖图片就足以看来label上的文字了。2、达成也是运用的和好评一样的法子。

// 关于触屏事件的一对操作
// 应用:刮奖(图片擦除 刮奖原理)
yzc579亚洲城官网,//
完成原理:当手指触摸到显示器上的时候,去到入手的某三个点,放大成四个圆柱形或然圆形,产生橡皮的认为,在滑行过的区域将图片刮除,展现下边包车型客车label或然其余view,应当要保证刮除的图样一定是晶莹的,不然看不到上面的label只怕view
// 先在ViewController里写多少个点子:
// 起始触摸的法子

9、

在铺子管理分界面,上传图片时,上传图片的调控器承接了三个特别用来拍卖张开相册然后单选或多选图片的三个根调整器。
在每一回选取完后本身都在跟调整器的- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info的方法里写了一个block,如图

yzc579亚洲城官网 8

16B947FE-6A73-48DA-8DB8-F64BEF301807.png

结果每便间接带出去的图纸上传成功并一直赋值成功后,如图

yzc579亚洲城官网 9

F5935665-B273-4C16-BF08-0FF83DE3384C.png

都会内部存款和储蓄器暴涨(【或然】原因本属于父亲和儿子调控器并不可能如此用block管理传值)
消除:在根调节器中写了一个措施

yzc579亚洲城官网 10

荧屏快速照相 2017-01-06 上午9.33.37.png

然后在

yzc579亚洲城官网 11

6D376D69-A073-43AE-8B75-FBD282054281.png

yzc579亚洲城官网 12

84474583-FB56-4F86-ADFD-80F4E486D636.png

如此获取image并上传并且赋值后,内部存款和储蓄器依旧会涨,但剥离该页面后,内部存款和储蓄器也降下来了

小结:父亲和儿子调整器传值一般直接在父调控器写三个主意(并在里边赋值),然后子调控器间接调用该格局,就能够获取该值==>

- touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {//得到移动时候的点UITouch *touch = [touches anyObject];CGPoint contentPoint = [touch locationInView:coverImageView];//清除的大小CGRect rect = CGRectZero;if (pointSize.width) { rect = CGRectMake(contentPoint.x, contentPoint.y, pointSize.width, pointSize.height);}else{ rect = CGRectMake(contentPoint.x, contentPoint.y, 10, 10);}//得到图片的一个视图UIGraphicsBeginImageContextWithOptions(coverImageView.bounds.size, NO, 0);//获取上下文CGContextRef ref = UIGraphicsGetCurrentContext();//将图片映射到上下文中[coverImageView.layer renderInContext:ref];//清除划过的区域CGContextClearRect(ref, rect);//获取图片UIImage *image = UIGraphicsGetImageFromCurrentImageContext();//关闭上下文UIGraphicsEndImageContext();coverImageView.image = image;}//点击结束,判断文字的四个角是否都完全显示出来,显示出来就回调,然后执行刮开后的代码- touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {CGPoint leftTopPoint = [self convertPoint:_textLabel.frame.origin toView:coverImageView];CGPoint leftBottomPoint = [self convertPoint:CGPointMake(_textLabel.frame.origin.x, _textLabel.y + _textLabel.height * 0.5) toView:coverImageView];CGPoint rightTopPoint = [self convertPoint:CGPointMake(_textLabel.x +_textLabel.width * 0.5, _textLabel.y) toView:coverImageView];CGPoint rightBottomPoint = [self convertPoint:CGPointMake(_textLabel.x +_textLabel.width * 0.5, _textLabel.y + _textLabel.height * 0.5) toView:coverImageView];if ([self isOpaqueWithPoint:leftTopPoint]&&[self isOpaqueWithPoint:leftBottomPoint]&&[self isOpaqueWithPoint:rightBottomPoint]&&[self isOpaqueWithPoint:rightTopPoint]) { if ([self.delegate respondsToSelector:@selector(scratchViewTextShow:)]) { [self.delegate scratchViewTextShow:self]; } }}//判断某个点是否透明-isOpaqueWithPoint:point{unsigned char pixel[1]={0};CGContextRef context = CGBitmapContextCreate(pixel,1,1,8,1,NULL,kCGImageAlphaOnly);UIGraphicsPushContext;[coverImageView.image drawAtPoint: CGPointMake(-point.x,-point.y)];UIGraphicsPopContext();CGContextRelease;CGFloat alpha = pixel[0]/255.0f;BOOL transparent = alpha<0.01f;return transparent;}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    // 获取手指
    UITouch *touch = [touches anyObject];
    // 判断手指是否在触摸
    if (touch.view == self.imageB) {
        self.isTouch = YES;
        NSLog(@"开始触摸");
    }
}

10、

JSONModel的使用:
建立model类继承JsonModel
1、解一个独门model,

model.h类:
@interface AccountModel : JSONModel
@property (nonatomic,strong) NSString *createtime;
@property (nonatomic,strong) NSString *createdate;
@end

model.m:
@implementation AccountModel
@end

API中:

AccountModel *Model = [[AccountModel alloc]initWith
Dictionary:responseObject[@"data"] error:&error];

2解出二个array(类似如下,解出list)

{
     "code": "1", 
      "data": { 
              "list": [ 
                   { "account_description": "在商家", 
                              "createdate": "01-06", 
                              "createtime": "11:09"
                   }
                  、、、
                  、、、
                     ]
           }
}

model类如下,.h中

yzc579亚洲城官网 13

4800173A-D491-4CEF-9AF3-5242D1D5A3B6.png

.m中

yzc579亚洲城官网 14

显示屏快速照相 2017-01-09 清晨4.08.23.png

API中:
   NSMutableArray *accountArr = [NSMutableArray array];
   NSError *err = nil;//都要写
   NSArray *data = responseObject[@"data"][@"list"];
   accountArr = [AccountModel arrayOfModelsFromDictionaries:data 
error:&err];

一经涉嫌后台给的字段有@“id” 或然@“description”,能够由此艺术转变下就可以

大约就那些步骤了,如有供给能够下载:

// 触摸移动的不二等秘书诀

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if (self.isTouch) {
        // 开启上下文      UIGraphicsBeginImageContextWithOptions(self.imageB.frame.size, NO, 0); //参数NO为设置不透明, 0为不进行缩放.
        // 把图片绘制到图像上下文中
        [self.imageB.image drawInRect:self.imageB.bounds];
        // 清空手指触摸的位置
        // 拿到手指, 根据手指的位置, 让对应的位置成为透明
        UITouch *touch = touches.anyObject;
        CGPoint point = [touch locationInView:touch.view];
        CGRect rect = CGRectMake(point.x - 10, point.y - 10, 20, 20);
        // 清除划过的区域
        CGContextClearRect(UIGraphicsGetCurrentContext(), rect);
        // 取出之后的图片赋值给imageB
        self.imageB.image = UIGraphicsGetImageFromCurrentImageContext();
        // 关闭图像上下文
        UIGraphicsEndImageContext();
        NSLog(@"触摸移动");
    }
}

// 触摸甘休的方法

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.isTouch = NO;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end

运转之后的结果如下:

yzc579亚洲城官网 15

QQ20160722-2.png

中间使用到的材质

yzc579亚洲城官网 16

afterA.jpg

yzc579亚洲城官网 17

preB.jpg

Author

发表评论

电子邮件地址不会被公开。 必填项已用*标注