欢迎使用CSDN-markdown编辑器

来源:互联网 发布:超图软件实施待遇 编辑:程序博客网 时间:2024/05/29 03:36

更新Xcode7 iOS9 后 SDWebImage 加载不了图片

在Info.plist中添加NSAppTransportSecurity类型Dictionary。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

//作为数据源
NSMutableArray *_dataArr;
//表格视图
UITableView *_myTableView;

//先创建数据
[self creatDate];
//然后再画视图
[self creatUI];

//两份协议
@interface ViewController ()

pragma mark -tablevie

//设置表格的行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_dataArr count];

}

-(UITableViewCell*)tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath )indexPath
{
// cell即将出现的时候调用

//一个静态的字符串作为cell的标示符static NSString *identifier=@"cell";//indexPath.row 代表的是cell的行数NSLog(@"即将出现%ld",indexPath.row);//涌过标示符 在tableview 的复用队列里面查询cellUITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];if (cell==nil) {    //如果在复用队列里没有查询结果,创建一个新的cell    cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];     NSLog(@"即将创建%ld",indexPath.row);}//if条件结束后必然会有一个cell 需要修改cell里面的内容cell.textLabel.text=[_dataArr objectAtIndex:indexPath.row];cell.tag=indexPath.row;UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click:)];[cell addGestureRecognizer:tap];return cell;

}
-(void)click:(UITapGestureRecognizer *)tap
{
NSLog(@”————–%ld”,tap.view.tag);
nextViewController *view=[[nextViewController alloc]init];
view.view.backgroundColor=[UIColor yellowColor];
view.label.textAlignment=NSTextAlignmentCenter;
view.str=_dataArr[tap.view.tag];
[view set];
[self presentViewController:view animated:YES completion:nil];
}

消除警告

define SuppressPerformSelectorLeakWarning(Stuff) \

do { \      _Pragma("clang diagnostic push") \      _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \      Stuff; \      _Pragma("clang diagnostic pop") \  } while (0)  

[objc] view plain copy
SuppressPerformSelectorLeakWarning(
[_target performSelector:_action withObject:self]
);
id result;
SuppressPerformSelectorLeakWarning(
result = [_target performSelector:_action withObject:self]
);

1.tablecell高度自动计算

1lable 在cell里面有4角约束

self.mytableView.estimatedRowHeight = 44.0f;
self.mytableView.rowHeight = UITableViewAutomaticDimension;

[self.imgview.layer setMasksToBounds:YES];允许设置圆角

define RGB(r, g, b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0]

define RGB2(r, g, b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

textField.placeholder = @”username is in here!”;
[textField setValue:[UIColor redColor] forKeyPath:@”_placeholderLabel.textColor”];
[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@”_placeholderLabel.font”];
m15021387157@163.com Xjx585858!

socket http://www.cnblogs.com/dolphinX/p/3460545.html

//开通推送功能 只有真机才有效果,模拟器无效
// ios7 ios8 不同
if ([UIDevice currentDevice].systemVersion.doubleValue<8.0) {
[ application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound ];
}
else
{
[application registerForRemoteNotifications];
UIUserNotificationSettings *settings=[UIUserNotificationSettings settingsForTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:settings];
}

  • (void)application:(UIApplication )application didRegisterUserNotificationSettings:(UIUserNotificationSettings )notificationSettings{
    // 成功注册了相关的推送类型
    }

//收到苹果服务器传回来的 唯一标示
- (void)application:(UIApplication )application didRegisterForRemoteNotificationsWithDeviceToken:(NSData )deviceToken{

}

//注册推送服务失败
- (void)application:(UIApplication )application didFailToRegisterForRemoteNotificationsWithError:(NSError )error{
NSLog(@”error is %@”, error);
}

//收到服务器发送的消息
- (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo{

}

IOS常用正则表达式 正则表达式用于字符串处理、表单验证等场合,实用高效。现将一些常用的表达式收集于此,以备不时之需。

匹配中文字符的正则表达式: [\u4e00-\u9fa5]
评注:匹配中文还真是个头疼的事,有了这个表达式就好办了

匹配双字节字符(包括汉字在内):[^\x00-\xff]
评注:可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)

匹配空白行的正则表达式:\n\s*\r
评注:可以用来删除空白行

匹配HTML标记的正则表达式:<(\S*?)[^>]>.?

0 0