//设置uiscrollview 里面的contentView 的宽度
NSDictionary *views = NSDictionaryOfVariableBindings(_contentView );
NSString *contentViewWidthStr=[NSString stringWithFormat:@"[_contentView(%f)]",kDeviceWidth];
NSDictionary *views = NSDictionaryOfVariableBindings(self.view,floatView );
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[floatView]|" options:0 metrics:0 views :views]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[floatView(==42)]|" options:0 metrics:0 views :views]];
floatView.hidden=YES ;
[floatView addSubview :phoneFollowButton];
[floatView addSubview :visitFollowButton];
NSDictionary *buttonsDictionary = NSDictionaryOfVariableBindings(floatView ,phoneFollowButton,visitFollowButton);
[floatView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[phoneFollowButton(==visitFollowButton)][visitFollowButton]|" options:0 metrics:0 views :buttonsDictionary]];
[floatView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[phoneFollowButton]|" options:0 metrics:0 views :buttonsDictionary]];
[floatView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[visitFollowButton]|" options:0 metrics:0 views:buttonsDictionary]];
- 对于两个同层级View之间的约束关系,添加到他们的父View上。
- 对于两个不同层级View之间的约束关系,添加到他们最近的共同的父View上
- 对于有层次关系的两个View之间的约束关系,添加到层次较高的父View上
-( void)showDetailFollowInfo:(Follow *)lookFollow{
showFollowInfoView=[[UIView alloc]init ];
showFollowInfoView.backgroundColor=[UIColor whiteColor ];
showFollowInfoView.frame=CGRectMake(0, 0, kDeviceWidth, [[UIScreen mainScreen] currentMode].size.height/2 );
[[UIApplication sharedApplication].keyWindow addSubview:showFollowInfoView ];
UILabel *showFollowDetailLabel=[[UILabel alloc]init];//WithFrame:CGRectMake(20, 0, 280, 21)
showFollowDetailLabel. text=lookFollow.content ;
showFollowDetailLabel.numberOfLines=0 ;
[showFollowDetailLabel sizeToFit];
showFollowDetailLabel.lineBreakMode=NSLineBreakByTruncatingTail;
//创建了一个水平居中父视图的约束
NSLayoutConstraint *constraint = [
NSLayoutConstraint
constraintWithItem :showFollowDetailLabel
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:showFollowInfoView
attribute:NSLayoutAttributeCenterX
multiplier:1.0f
constant:00.0f
NSLayoutConstraint
constraintWithItem :showFollowDetailLabel
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:showFollowInfoView
attribute:NSLayoutAttributeCenterY
multiplier:1.0f
constant:00.0f
];
[ showFollowInfoView addConstraint :constraint];
[showFollowInfoView addConstraint:constraint1];
showFollowInfoView.userInteractionEnabled=YES ;
UITapGestureRecognizer *tapGestrue = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeFollowShowView:)];
for (ForumThread *forumThreadUse in childObjects) {
//在返回数据的时候得到对象cell的Frame
ForumThreadFrame *forumThreadFrameNow=[[ForumThreadFrame alloc]init ];
forumThreadFrameNow.forumThread =forumThreadUse;
[childObjectsFrameArr addObject:forumThreadFrameNow];
return [[self.paginator.results objectAtIndex:indexPath.row] cellHeight]; //获得话题cell的高度
follow = [self.paginator.results objectAtIndex:indexPath.row ];
//如果两次点击的时间间隔小于1秒,则断定为双击事件
NSUInteger curr = [[NSDate date] timeIntervalSince1970 ];
if (curr-taptime<1 ) {
[self showDetailFollowInfo:follow ];
}
taptime = curr;
cell = [[NSBundle mainBundle] loadNibNamed:@"CommissionerCell" owner:nil options:nil][0];
markImageView.image=[UIImage imageNamed:@"selected@2x.png" ];
}
int positionTag=1 ;
for (Team *team in self.paginator.results ) {
team.positionTag=[NSString stringWithFormat:@"%d" ,positionTag];
positionTag++;
NSMutableString *preString = [string mutableCopy ];
/*转换成成带音 调的拼音*/
if( CFStringTransform((CFMutableStringRef)preString, NULL, kCFStringTransformMandarinLatin, NO )){}
/*去掉音调*/
if(CFStringTransform((CFMutableStringRef)preString, NULL, kCFStringTransformStripDiacritics, NO )){}
svn不能提交.a文件, 这个主要与SVN的配置有关. 解决方法如下:
- 打开终端, 在命令行中输入: open ~/.subversion/config 来打开配置文件.
- 然后, 在文件中搜索 [auto-props] ,并在它上面添加:
global-ignores=.o .lo .la .al .libs .so .so.[0-9] .pyc .pyo .rej ~ ## .# ..swp .DS_Store .xcuserstate
3.保存,刷新svn,你会发现svn 对 .a 文件的 标识 不再是 i,而是 ? ,这说明 .a 文件 已经在svn的控制中了,然后 add 。commit
这里的意思是, SVN在提交时自动忽略以这些后缀的文件, 那么我们要去掉.a这一项, 则将配置文件改为
global-ignores = .o .lo .la .al .libs .so .so.[0-9] .pyc .pyo .rej ~ ## .# .*.swp .DS_Store
保存退出. 就可以了.
if(iOS7){
#pragma -mark ActionSheet 委托 的点击按钮事件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger )buttonIndex{
if(buttonIndex==0){ //保存图片到本地相册
if(needSaveImage!=nil ){
UIImageWriteToSavedPhotosAlbum(needSaveImage, self,@selector(image:didFinishSavingWithError:contextInfo:),nil );
}
{
// Handle the end of the image write process
if (!error)
[self initHudWithCaptionOnly:@"已保存到本地相册" ];
else
[ self initHudWithCaptionOnly:[NSString stringWithFormat:@"保存错误: %@",error]];
{
UIImage* originalImage = [UIImage imageNamed:imageName];
CGRect rect = CGRectMake(0, 0, 29, 29 );
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0.0 );
CGContextRef context = UIGraphicsGetCurrentContext();
[originalImage drawInRect:CGRectMake(0, 0, 29, 29)]; //图片大小
CGRect borderRect = CGRectMake( 21.0, 0.0, 8.0, 8.0); //点大小
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0 );
CGContextSetFillColorWithColor(context,[UIColor redColor].CGColor);
CGContextSetLineWidth(context, 1.0 );
CGContextFillEllipseInRect (context, borderRect);
CGContextStrokeEllipseInRect(context, borderRect);
CGContextFillPath(context);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
label.numberOfLines =publicLineNum;
label.text =contextStr;
CGRect rect =label.frame ;
CGSize sizeToFit = [label sizeThatFits:CGSizeMake(rect.size.width, MAXFLOAT )];
rect.size.height = sizeToFit.height ;
label.frame = rect;
label.lineBreakMode = UILineBreakModeTailTruncation; //UILineBreakModeTailTruncation , UILineBreakModeWordWrap 截去尾部
}
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:dataText];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, dataText.length)];
[dataInfoLable sizeToFit]; //长宽都自动适应。
dataInfoLable. lineBreakMode = UILineBreakModeTailTruncation; //UILineBreakModeTailTruncation, UILineBreakModeWordWrap 截去尾部
}
NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:contextStr];
[content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range :contentRange];
label.attributedText = content;
NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString :lightValue];
NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init ];
[paragraphStyle1 setLineSpacing:2 ];
[attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, lightValue.length )];
[targetLable setAttributedText :attributedString1];
[targetLable sizeToFit];
- (void)callPhone:(UITapGestureRecognizer *)gesture
{
UIActionSheet *actionSheet = [[UIActionSheet alloc ]
initWithTitle:[NSString stringWithFormat:@"联系客户:%@",_customer.customerName ]
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:_customer.customerTel
otherButtonTitles:@"复制",nil ];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault ;
[actionSheet showInView:self.view ];
}
#pragma -mark ActionSheet 委托 的点击按钮事件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger )buttonIndex{
if(buttonIndex==0 ){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[ NSString stringWithFormat:@"tel://%@",_customer.customerTel ]]];
}else if(buttonIndex==1 ){
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard ];
NSString *pastContext=[NSString stringWithFormat:@"%@ %@",_customer.customerName,_customer.customerTel ];
pasteboard.string = pastContext;
}
}
NSDictionary *dic=(NSDictionary *)extendData;
NSString *rolesType=[NSString stringWithFormat:@"%@",[dic objectForKey:@"rolesType" ]];
// 进行保存权限
[[ NSUserDefaults standardUserDefaults] setObject:rolesType forKey:AGENT_ROLE ];
[[NSUserDefaults standardUserDefaults] synchronize ];
[self close:nil ];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate ];
if([rolesType isEqualToString:@"1"]||[rolesType isEqualToString:@"0"]){ //专员
//选中第1个点tab
[appDelegate. tabBarController setSelectedIndex:0 ];
}if([rolesType isEqualToString:@"2"]){ //售楼员
//选中第2个tab
[appDelegate. tabBarController setSelectedIndex:1 ];
}if([rolesType isEqualToString:@"3"]){ //专员、售楼员
//选中第1个tab
[appDelegate. tabBarController setSelectedIndex:0 ];
}
[self reloadSalesPerson :appDelegate];
[self reloadCommissioner :appDelegate];
[self reloadMessageList :appDelegate];
}
NSString *isClickedSecond=[[NSUserDefaults standardUserDefaults] objectForKey:@"HaveClickSecond" ];
if([isClickedSecond isEqualToString:@"1" ]){
//判断售楼员模块是否点击过,如果点击过了则刷新售楼员模块
UIViewController *navController=[appDelegate.tabBarController.viewControllers objectAtIndex:1 ];
if([navController isKindOfClass:[UINavigationController class ]])
{
UINavigationController *navCtrl = (UINavigationController *)navController;
CustomerListViewController *customerListViewController=(CustomerListViewController*)[navCtrl.viewControllers objectAtIndex:0 ];
if(customerListViewController!=nil ){
[customerListViewController reloadCustomerList ];
}
}
}
}
NSDictionary *operateDic = [data objectFromJSONData];//JSONKit中的解析函数 objectFromJSONData
keyWord=[StringUtil urlEncode:keyWord];
{
//make sure param is a string
if ([value isKindOfClass:[NSNumber class ]]) {
value = [(NSNumber*)value stringValue ];
}
NSAssert([value isKindOfClass:[NSString class]], @"request parameters can be only of NSString or NSNumber classes. '%@' is of class %@.", value, [value class ]);
return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes (
NULL ,
(__bridge CFStringRef ) value,
NULL ,
(CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8 ));
}
-(void) ajax:(NSString *)url params:(NSDictionary *)dic withArray:(BOOL)isWithArray dialog:(BOOL )isShowDialog{
if (isShowDialog){
[self initHudWithCaptionAndActivity ];
}
if([url isEqualToString:URL_LOGIN ]){
[[NSUserDefaults standardUserDefaults] removeObjectForKey:COOKIE ];
}
formDataRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString :url]];
[formDataRequest setRequestMethod:@"POST" ];
[formDataRequest setUseCookiePersistence:NO ];
formDataRequest.delegate = self ;
NSString *cookies = [[NSUserDefaults standardUserDefaults] objectForKey:COOKIE ];
if (cookies){
[formDataRequest addRequestHeader:@"Cookie" value :cookies];
}
NSEnumerator *emkey = [dic keyEnumerator ];
for (NSObject *key in emkey) {
id arr=[dic objectForKey :key];
if([arr isKindOfClass:[NSArray class]]||[arr isKindOfClass:[NSMutableArray class ]]){
NSArray *sendArr=arr;
for (id obj in sendArr) {
[formDataRequest addPostValue:obj forKey:[key description]]; //向同一个key 添加值,就是成数组了。
}
} else {
[formDataRequest addPostValue:[dic objectForKey:key] forKey:[key description ]];
}
}
[formDataRequest setTimeOutSeconds:20 ];
[formDataRequest startAsynchronous ];
}
-( UIImage*)scaleToSize:(UIImage*)img size:(CGSize )size
{
// 创建一个bitmap的context
// 并把它设置成为当前正在使用的context
UIGraphicsBeginImageContext (size);
// 绘制改变大小的图片
[img drawInRect:CGRectMake(0, 0, size.width, size.height )];
// 从当前context中创建一个改变大小后的图片
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext ();
// 使当前的context出堆栈
UIGraphicsEndImageContext ();
// 返回新的改变大小后的图片
return scaledImage;
}
// 按钮上显示文字和图片 :左边文字,右边图片
[showMoreButton setImageEdgeInsets:UIEdgeInsetsMake(0, showMoreButton.titleLabel.bounds.size.width, 0, -showMoreButton.titleLabel.bounds.size.width )];
[showMoreButton addTarget:self action:@selector(showMore:) forControlEvents:UIControlEventTouchUpInside];
NETWORK_TYPE_NONE= 0 ,
NETWORK_TYPE_WIFI= 1 ,
NETWORK_TYPE_3G= 2 ,
NETWORK_TYPE_2G= 3 ,
}NETWORK_TYPE;
//然后通过获取手机信号栏上面的网络类型的标志
+ ( int )dataNetworkTypeFromStatusBar {
UIApplication *app = [UIApplication sharedApplication ];
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews ];
NSNumber *dataNetworkItemView = nil ;
for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class ]]) {
dataNetworkItemView = subview;
break ;
}
}
int netType = NETWORK_TYPE_NONE ;
NSNumber * num = [dataNetworkItemView valueForKey:@"dataNetworkType" ];
if (num == nil ) {
netType = NETWORK_TYPE_NONE ;
}else {
int n = [num intValue ];
if (n == 0 ) {
netType = NETWORK_TYPE_NONE ;
}else if (n == 1 ){
netType = NETWORK_TYPE_2G ;
}else if (n == 2 ){
netType = NETWORK_TYPE_3G ;
}else {
netType = NETWORK_TYPE_WIFI ;
}
}
return netType;
1, 错误信息:
"_OBJC_CLASS_$ xxxxx ", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决方法:
查看工程,看是不是没有导入相关的框架。或者工程里添加的有相同".m",".h" 文件
2, 错误信息:
Couldn't register dy.CKRiLiText with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.Current language: auto; currently objective-c
解决方法: 可能是电脑内存问题引起,重启电脑即可解决。如果重启解决不了问题,那就是你刚刚改动的代码引起的问题。
3 、 错误信息:
ios 5是调试正常的,ios 6真机调试的时候,出现如下错误:ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/mac4/Desktop/my desktop/My app/MyApp name 20:09:12 /MyApp name/ZBarSDK/libzbar.a for architecture armv7serror: linker command failed with exit code 1 (use -v to see invocation)
解决方法:在Xcode里,点击相应的Target,然后点Build Settings,找到VALID_ARCHS,看里面的是不是arvm7s,如果不是改成arvm7s就可以了。
4 、 错误信息:
error: receiver type 'ViewController' for instance message does not declare a method with selector 'hideSearchBar:' [4]
ViewController 中没有声明一个方法选择'hideSearchBar:
解决方法:
在ViewController .h 中声明一下这个方法 “ hideSearchBar ” 即可。
5、 错误信息:当json从服务端请求时得到的字符串,如果这样写的话,会报错,';' after top level declarator
NSString *ss= @"{"recommend":"世界末日","dogname":"机器人"}";
解决方法:
就是,把 “ 替换成 \" 即可。NSString *ss= @"{ \"recommend \": \"世界末日 \", \"dogname \": \"机器人 \"}";
6 、 错误信息:
error: Existing instance variable '_datasource' for property 'datasource' with assign attribute must be __unsafe_unretained
解决方法:
id _datasource; 改为 __unsafe_unretained id _datasource:即可
7 、 错误信息:
error: No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).
解决方法:
targets ->build setting 下的 Build Active Architecture Only 设置 NO 即可.
NSArray allPictures=[[],[],[],[] ];
点击某个相册: index
图片滑到了第几张呢? 如果点击的相册不是第一个相册。 allPictures[index-1].count +1 否则: 1 张。
从外面点击图片进来选中图片:
查找到图片在哪个相册index, 第几张page,如果找到的图片不在第一个相册 。 allPictures[index-1].count + page 否则: page
//单击了哪张图片
- ( void)clickWhichImageView:(NSInteger )curImgPage;
//返回状态,判断是上一个相册,还是下一个相册
- ( void)changeAlbum:(NSInteger )status;
//是否点击切换的
-( BOOL )isClickChange;//用户更换相册的时候,确定到底是点击到另外的相册还是滑动到另外的相册,因为如果是点击的,如果为空也可以直接显示。
//是否遇到空相册
-( BOOL)isSlideMeetEmptyPicture; //在滑动上下相册的时候,检测是否遇到了空相册
-( void)resetIsSlideMeetEmptyPicture; //重置遇到空相册的状态
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
-(void) scrollViewDidScroll:(UIScrollView *)scrollView
[[ NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey" ];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDiskImageCacheEnabled" ];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitOfflineWebApplicationCacheEnabled"];
NSData *newHouseDetailObject = [NSKeyedArchiver archivedDataWithRootObject :NHD];
localLastTuanGouDetailKey=[NSString stringWithFormat:@"lastTuanGouDetail_%@",_tgID ];
newHouseDetailObject=[[NSUserDefaults standardUserDefaults] objectForKey:localLastTuanGouDetailKey]; //上一次的对象
NHD= [ NSKeyedUnarchiver unarchiveObjectWithData :newHouseDetailObject] ;
newHouse =NHD;
if(newHouse!=nil){ //本地有缓存的时候,直接从缓存中显示出来
[ self reloadNewHouseDetialData];
- ( id) initWithCoder: (NSCoder *)coder
{
if (self = [super init])
{
// Decode the property, and use the KVC setValueForKey: method to set it
id value = [coder decodeObjectForKey :key];
[self setValue:value forKey:key];
- ( void) encodeWithCoder: (NSCoder *)coder
{
// Loop through the properties
for (NSString *key in [self propertyNames:[self class ]])
{
// Use the KVC valueForKey: method to get the property and then encode it
id value = [self valueForKey :key];
[coder encodeObject:value forKey :key];
}