当前位置:  编程技术>移动开发
本页文章导读:
    ▪判断信箱是否合法        判断邮箱是否合法 方法1: BOOL NSStringIsValidEmail(NSString *checkString)  {      NString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";      NSString *laxString = @".+@.+\.[A-Za-z]{2}[A-Za-z]*";   .........
    ▪ MapKit之在map下加pin(转)        MapKit之在地图上加pin(转) 在MKMapView中加pin其实就是加入MKAnnonation, 可以加入服和MKAnnonation协议的pin,下面展示一下方法。1.首先创建一个服和MKAnnonation协议的委托类 @interface AnnotationDelegate .........
    ▪ HTC Desire G7 ROOT 注意事项:ROM扰乱       HTC Desire G7 ROOT 注意事项:ROM干扰 Desire G7 在破解ROOT(无痛ROOT或者彻底ROOT S-OFF)成功率会受到ROM的干扰。   推荐破解ROOT的时候ROM安装官方的或者官方修改版,或其他小体积ROM,新机通常是.........

[1]判断信箱是否合法
    来源: 互联网  发布时间: 2014-02-18
判断邮箱是否合法

方法1:

BOOL NSStringIsValidEmail(NSString *checkString) 

    NString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; 
    NSString *laxString = @".+@.+\.[A-Za-z]{2}[A-Za-z]*"; 
    NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; 
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; 
    return [emailTest evaluateWithObject:checkString]; 
}

方法2:

-(BOOL)validateEmail:(NSString*)email{
   
    if( (0 != [email rangeOfString:@"@"].length) &&  (0 != [email rangeOfString:@"."].length) )
    {
        NSMutableCharacterSet *invalidCharSet = [[[[NSCharacterSet alphanumericCharacterSet] invertedSet]mutableCopy]autorelease];
        [invalidCharSet removeCharactersInString:@"_-"];
       
        NSRange range1 = [email rangeOfString:@"@" options:NSCaseInsensitiveSearch];
       
        // If username part contains any character other than "."  "_" "-"
       
        NSString *usernamePart = [email substringToIndex:range1.location];
        NSArray *stringsArray1 = [usernamePart componentsSeparatedByString:@"."];
        for (NSString *string in stringsArray1) {
            NSRange rangeOfInavlidChars=[string rangeOfCharacterFromSet: invalidCharSet];
            if(rangeOfInavlidChars.length !=0 || [string isEqualToString:@""])
                return NO;
        }
       
        NSString *domainPart = [email substringFromIndex:range1.location+1];
        NSArray *stringsArray2 = [domainPart componentsSeparatedByString:@"."];
       
        for (NSString *string in stringsArray2) {
            NSRange rangeOfInavlidChars=[string rangeOfCharacterFromSet:invalidCharSet];
            if(rangeOfInavlidChars.length !=0 || [string isEqualToString:@""])
                return NO;
        }
       
        return YES;
    }
    else // no ''@'' or ''.'' present
        return NO;
}


    
[2] MapKit之在map下加pin(转)
    来源: 互联网  发布时间: 2014-02-18
MapKit之在地图上加pin(转)
在MKMapView中加pin其实就是加入MKAnnonation, 可以加入服和MKAnnonation协议的pin,下面展示一下方法。

1.首先创建一个服和MKAnnonation协议的委托类
@interface AnnotationDelegate : NSObject <MKAnnotation> {  
    CLLocationCoordinate2D coordinate;  
}  
    
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;  
    
- (id) initWithCoordinate:(CLLocationCoordinate2D)coord;  
    
@end  
    
@implementation AnnotationDelegate  
    
@synthesize coordinate;  
    
- (id) initWithCoordinate:(CLLocationCoordinate2D)coord  
{  
    coordinate.latitude = coord.latitude;  
    coordinate.longitude = coord.longitude;  
    return self;  
}  
    
@end  

2. 实例化该委托对像,加入到MKMapView中。
view plaincopy to clipboardprint?
AnnotationDelegate * annotationDelegate = [[[AnnotationDelegate alloc] initWithCoordinate:coordinate] autorelease];  
[self._mapView addAnnotation:annotationDelegate];  

另一处介绍
#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>
@interface DisplayMap : NSObject
<MKAnnotation>{
    CLLocationCoordinate2D coordinate;
    NSString *title;
    NSString *subtitle;
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@end
 
 
#import "DisplayMap.h"
@implementation DisplayMap
@synthesize coordinate,title,subtitle;
-(void)dealloc{
    [title release];
    [super dealloc];
}
@end

修改viewDidLoad方法
- (void)viewDidLoad {
    [super viewDidLoad];
    //mapView.showsUserLocation=YES;
    self.mapView.delegate=self;
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];//创建位置管理器
    locationManager.delegate=self;//设置代理
    locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度级别
    locationManager.distanceFilter=1000.0f;//设置距离筛选器
    [locationManager startUpdatingLocation];//启动位置管理器
  
    MKCoordinateRegion theRegion = { {0.0, 0.0 }, { 0.0, 0.0 } };
    theRegion.center=[[locationManager location] coordinate];
    [locationManager release];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    theRegion.span.longitudeDelta = 0.01f;
    theRegion.span.latitudeDelta = 0.01f;
    [mapView setRegion:theRegion animated:YES];
    DisplayMap *ann = [[DisplayMap alloc] init];
    ann.title = @"欧陆经典";
    ann.subtitle = @"vsp";
    //地点名字
    ann.coordinate = theRegion.center;
    [mapView addAnnotation:ann];
}
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinView = nil;
    if(annotation != mapView.userLocation)
    {
        static NSString *defaultPinID = @"com.invasivecode.pin";
        pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
                                          initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
        pinView.pinColor = MKPinAnnotationColorRed;
        pinView.canShowCallout = YES;
        pinView.animatesDrop = YES;
    }
    else {
        [mapView.userLocation setTitle:@"欧陆经典"];
    [mapView.userLocation setSubtitle:@"vsp"];
    }
    return pinView;
}

注意:无论是自定义的MKAnnotationView还是标准的,一旦addAnnotation to MapView,如何更新它在地图上的位置呢?更新MKAnnotation protocol中的coordinate可以做到吗? 如果是手动更新位置是不可以让它在地图上移动的。请看官网文档 ,其中有一段描述:
“Important: When you implement the coordinate property in your class, it is recommended that you synthesize its creation. If you choose to implement the methods for this property yourself, or if you manually modify the variable underlying that property in other parts of your class after the annotation has been added to the map, be sure to send out key-value observing (KVO) notifications when you do. Map Kit uses KVO notifications to detect changes to the coordinate, title, and subtitle properties of your annotations and make any needed changes to the map display. If you do not send out KVO notifications, the position of your annotations may not be updated properly on the map.For more information about how to implement KVO-compliant accessor methods, see Key-Value Observing Programming Guide.”

手动更新后必须用KVO的方式通知系统,不然系统是不知道更新位置的。如何通知道呢,其实NSObject中有这样的方法willChangeValueForKey and didChangeValueForKey。如你写了个方法更新pin位置,如下:
view sourceprint?-(void)UpdateCoord:(CLLocationCoordinate2D)newCoord   
{   
        [self willChangeValueForKey:@"coordinate"];   
        coordinate = newCoord;   
        [self didChangeValueForKey:@"coordinate"];   
}

IOS4中更新更简单,只需要调用- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate;这个方法就可以自动更新了。

    
[3] HTC Desire G7 ROOT 注意事项:ROM扰乱
    来源: 互联网  发布时间: 2014-02-18
HTC Desire G7 ROOT 注意事项:ROM干扰

Desire G7 在破解ROOT(无痛ROOT或者彻底ROOT S-OFF)成功率会受到ROM的干扰。

 

推荐破解ROOT的时候ROM安装官方的或者官方修改版,或其他小体积ROM,新机通常是官网原版不牵扯本文讲的问题

 

 

无痛ROOT即unrEVOked工具刷recovery,已经无痛ROOT的G7(S-ON)换刷别的recovery版本,

如果当前ROM为insertcoin,RCmixs,Reflex,Kingdom类ROM,那么失败率会很高,需要换回官方或官方修改版ROM

然后重新刷recovery。

 

彻底ROOT刷S-OFF也会受insertcoin,RCmixs,Reflex,Kingdom 这些ROM干扰同样要换回官方或官方修改版ROM然后重新刷S-OFF

 

 

S-OFF的机器可以用recovery自刷来更换RECOVERY,不再受ROM影响

 


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3