IOS OC语法
LONG_IOS
IOS
展开
-
IOS设计模式一:代理模式
代理模式实现方式如下:#import //声明协议,制定协议@protocol TRSubViewControllerDelegate//声明一个方法-(void)changeRootViewColor:(UIColor*)color;@end@interface TRSubViewController : UIViewController//设置一个可以外部访问的属性 -原创 2015-08-26 10:56:02 · 421 阅读 · 0 评论 -
在坐标中画出图片
- (void)drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); UIImage *image = [UIImage imageNamed:@"apple.png"]; [image drawInRect:CGRectMake(60, 340, 20, 20原创 2016-10-11 19:21:49 · 622 阅读 · 0 评论 -
ios Segue传值
ios Segue传值相关代码如下:[self performSegue:@"UserInfo_Setting" params:nil];- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ UserFriendViewController *vc = segue.destinationViewC原创 2015-09-07 13:41:59 · 506 阅读 · 0 评论 -
ios 转json字符串
ios 转json字符串相关代码如下://把字典和数组转换成json字符串- (NSString *)stringTOjson:(id)temps{ NSData* jsonData =[NSJSONSerialization dataWithJSONObject:temps options:NSJSONWritingPrettyPrinted error:nil]; NS原创 2015-09-06 18:25:42 · 1867 阅读 · 0 评论 -
ios 排序
ios 排序相关排序代码如下://冒泡排序-(void)bubblesort { for (int i = 0; i < self.label.count-1; i++) { UILabel *labi = self.label[i]; for (int j = i; j <self.label.count; j++原创 2015-09-06 18:10:38 · 380 阅读 · 0 评论 -
iOS通知:NSNotificationCenter
iOS通知:NSNotificationCenter 相关代码如下#pragma mark -微信支付回调-(void) onResp:(BaseResp*)resp{ [[NSNotificationCenter defaultCenter] postNotificationName:@"respNoti" object:resp];}//移除通知- (void)deal原创 2015-08-29 10:14:36 · 472 阅读 · 0 评论 -
NSDictionary
NSDictionary字典相关代码如下:不可变字典,以及添加不可变字典 [[NSMutableArray array] addObject:[[NSDictionary alloc]initWithObjectsAndKeys:@"盖伦",@"name",@"gailun.jpg",@"pic", nil]];可变字典,以及可变字典的添加、删除 self.di原创 2015-08-27 14:58:24 · 419 阅读 · 0 评论 -
IOS传值:block传值
Block传值代码如下:#import "TRRootBViewController.h"#import "TRRootAViewController.h"@interface TRRootBViewController ()@property (weak, nonatomic) IBOutlet UILabel *label;@property(nonatomic,strong)原创 2015-08-26 11:33:36 · 478 阅读 · 0 评论 -
IOS设计模式:单例以及单例传值
单例模式代码如下:#import "TRclas.h"static TRclas *share = nil;@implementation TRclas+(TRclas *)defaultNum{ if (!share) { share=[[TRclas alloc]init]; } return share;}@end原创 2015-08-26 11:47:51 · 528 阅读 · 0 评论 -
IOS传值:属性传值
属性传值如下:#import "TRRootAViewController.h"#import "TRRootBViewController.h"@interface TRRootAViewController ()@property (weak, nonatomic) IBOutlet UILabel *labelA;@property (weak, nonatomic) IBOu原创 2015-08-26 11:18:45 · 517 阅读 · 0 评论