05-5
1 "_OBJC_CLASS_$_Play", referenced from:
解决方案:
Tagert--Build Phases -- Compile Sources 下添加对应的.m文件
2. iOS addChildViewControlleriOS开发剖析网易新闻标签栏视图切换(addChildViewController属性介绍)
http://www.it165.net/pro/html/201406/16429.htmlIOS开发之自定义Button(集成三种回调模式)
http://www.it165.net/pro/html/201409/21930.html#pragma mark 可变字符串
- (NSAttributedString *)setCmtHeaderViewLabel:(NSString *)text
{
/**转为可变属性的字符串 */
NSMutableAttributedString *attrText = [[NSMutableAttributedStringalloc]initWithString:text] ;
NSLog(@"字符串长度为%ld" , text.length) ;
//颜色
UIColor *type1Color =kUIColorFromRGBWithAlapha(252,172,17,1);
[attrText addAttribute:NSForegroundColorAttributeNamevalue:type1Colorrange:NSMakeRange(4, text.length -4)];
[attrText addAttribute:NSFontAttributeNamevalue:[UIFontsystemFontOfSize:20]range:NSMakeRange(4, text.length -4)];
return attrText;
}
4.定义颜色宏
/// RGB 颜色和透明度
#define kUIColorFromRGBWithAlapha(RedValue ,GreenValue,BlueValue, AlphaValue ) [UIColor colorWithRed:RedValue/255.0 green:GreenValue/255.0 blue:BlueValue/255.0 alpha:AlphaValue]
5.学习http://www.it165.net/Pro/ydip/
6.视图缩放动画
http://bbs.youkuaiyun.com/topics/390655895?page=1
http://www.cnblogs.com/pengyingh/articles/2378732.html
一、编绎显示Unknown type name “CGFloat” 等 错误解决方法
将Compile Sources As 改为 Objective-C++
二、如果是extern const引起的。直接加头文件
#import <UIKit/UIKit.h>
开发中,经常会用到将int格式化成NSString,还在使用format(@"%d",int);那就过时了。
【新用法】看下面宏定义:
#define NSStringFromValue(value) [@(value) description]
可以这么使用:
NSStringFromValue( int 类型)
NSStringFromValue( float 类型) //long 型等,基础数据类型
NSStringFromValue( char* 类型)//C字符串奥,"hellowrold"
类似的宏定义还有:
#define NSStringFromBOOL(value) (value ? @"YES" : @"NO")
#define NSStringFromVariableName(variableName) @(#variableName)
http://blog.youkuaiyun.com/liyun123gx/article/details/45531737
4.手势~~~上下左右滑动
UISwipeGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[[self view] addGestureRecognizer:recognizer];
5.debugging 模式打开Xcode1 把delete改成中文删除,自定义上传按钮图片http://blog.youkuaiyun.com/xiaoxuan415315/article/details/7834940
//转换成拼音
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
//去掉音调
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripDiacritics, NO);
NSLog(@"pinyin= %@",pinyin);
NSString * first = [pinyin substringToIndex:1];
NSLog(@"%@", first);
// NSString * dateString =[dict objectForKey:@"createTime"];
// NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
// [inputFormatter setDateFormat:@"yyyy-MM-dd HH-mm-ss"];
// NSDate* inputDate = [inputFormatter dateFromString:dateString];
//
// NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
// dateFormatter1.dateFormat = @"( MM.dd ) HH:mm";
// NSString *dayTimeStr1 =[dateFormatter1 stringFromDate:inputDate];
//
//
// NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// dateFormatter.dateFormat = @"EE";
// [dateFormatter setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"]];//年月日转中文
//
//
// NSString *dayTimeStr =[dateFormatter stringFromDate:inputDate];
//
// // NSLog(@"%@======%@",dayTimeStr,dayTimeStr1);
//
// cell.timeLable.text =[NSString stringWithFormat:@"%@ %@",dayTimeStr,dayTimeStr1];
NSString * str = [NSString stringWithFormat:@"¥%.2f万",price];
NSString *tempStr = @"\\d{1,}";
NSMutableArray *results = [NSMutableArray array];
NSRange searchRange = NSMakeRange(0, [str length]);
NSRange range;
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:str];
while ((range = [str rangeOfString:tempStr options:NSRegularExpressionSearch range:searchRange]).location != NSNotFound)
{
[results addObject:[NSValue valueWithRange:range]];
searchRange = NSMakeRange(NSMaxRange(range), [str length] - NSMaxRange(range));
[string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:range];
}
cell.priceLable.attributedText = string;
if ([stringToConvert hasPrefix:@"#"]) {
stringToConvert = [stringToConvert substringFromIndex:1];
} else if ([stringToConvert hasPrefix:@"0x"]) {
stringToConvert = [stringToConvert substringFromIndex:2];
}
NSScanner *scanner = [NSScanner scannerWithString:stringToConvert];
unsigned hexNum;
if (![scanner scanHexInt:&hexNum]) return nil;
return [[self class] colorWithRGBHex:hexNum];
}
int r = (hex >> 16) & 0xFF;
int g = (hex >> 8) & 0xFF;
int b = (hex) & 0xFF;
return [UIColor colorWithRed:r / 255.0f
green:g / 255.0f
blue:b / 255.0f
alpha:1.0f];
}
UILabel * testlable = [[UILabel alloc]initWithFrame:CGRectMake(10,20,200,20)]; NSString * tstring =@"UILabel ios7 与ios7之前实现自适应撑高的方法,文本的内容长度不一,我们需要根据内容的多少来自动换行处理。在IOS7下要求font,与breakmode与之前设置的完全一致sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping"; testlable.numberOfLines =2; UIFont * tfont = [UIFont systemFontOfSize:14]; testlable.font = tfont; testlable.lineBreakMode =NSLineBreakByTruncatingTail ; testlable.text = tstring ; [testlable setBackgroundColor:[UIColor redColor]]; [self.view addSubview:testlable]; //高度估计文本大概要显示几行,宽度根据需求自己定义。 MAXFLOAT 可以算出具体要多高 CGSize size =CGSizeMake(300,60); // label可设置的最大高度和宽度 // CGSize size = CGSizeMake(300.f, MAXFLOAT); // 获取当前文本的属性 NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil]; //ios7方法,获取文本需要的size,限制宽度 CGSize actualsize =[tstring boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:tdic context:nil].size; // ios7之前使用方法获取文本需要的size,7.0已弃用下面的方法。此方法要求font,与breakmode与之前设置的完全一致 // CGSize actualsize = [tstring sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping]; // 更新UILabel的frame testlable.frame =CGRectMake(10,20, actualsize.width, actualsize.height);05-26
最近项目有需求, 需要模态初一个半透明的视图, 好多人都碰到这个问题吧, 在目标视图中设置背景颜色然后发现模态动作结束后变成了黑色或者不是半透明的颜色。
所以今天来告诉大家解决方案
- (IBAction)Avtion1:(id)sender {
TestViewController * testVC = [TestViewController new];
self.definesPresentationContext = YES; //self is presenting view controller
testVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.4];
testVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:testVC animated:YES completion:nil];
}
- 注意:如果present 一个NavController,不能完全使用上面代码。
- (IBAction)pushSecond:(id)sender{
SecondViewController * testVC = [SecondViewController new];
self.definesPresentationContext = YES; //self is presenting view controller
testVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.5];
// testVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:testVC];
nav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
nav.view.backgroundColor = [UIColor clearColor];
[self presentViewController:nav animated:YES completion:nil];
}
NSData* alarmInfoData = [json dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary * alarmInfoDic =[NSJSONSerialization JSONObjectWithData:alarmInfoDataoptions:NSJSONReadingMutableLeaves error:nil];
UITableViewCell 在IOS7的父视图是UITableViewWrapperView。
(2013-11-28 16:11:12)UITableView *tableView;
在IOS7以下系统,UITableViewCell.superview就是UITableView,但在IOS7中,cell上面还多了一个UITableViewWrapperView,所以需要UITableViewCell.superview.superview获取UITableView