@interface UIButton (AsyncImage) //size by point - (void)setImageFromURL:(NSString *)urlString adjustToSize:(CGSize)size completion:(void (^)(void))completion logo:(UIImage *)logoImage; @end @implemen
+ (UIImage *) imageFromView: (UIView *) theView { // Draw a view’s contents into an image context UIGraphicsBeginImageContext(theView.frame.size); CGContextRef context = UIGraphicsGetCurrentContext();
GET和POST请求是HTTP请求方式中最最为常见的。在说请求方式之前先熟悉 HTTP 的通信过程: 请求 1 、 请求行 : 请求方法、请求路径、 HTTP 协议的版本 GET /MJServer/resources/images/ 1. jpg HTTP/ 1.1 2、请求头 : 客户端的一些描述信息 Host : 192.168.1.111:8080 // 客户端想访问的服务器主机地址 Us
当前视图上有多个uitextfield时,来隐藏键盘, 先遍历视图的所有子视图来 如果是UITextField就将其设为非第一响应 当然,如果要隐藏子视图上的UITextField的话可以进一步判断view的subviews的个数,如果大于1则遍历view的子视图,然后作类似操作 //隐藏键盘 当前视图上有多个uitextfield for(UIView *view in [self.view s
SCNetworkReachabilityFlags flags; BOOL receivedFlags; SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(CFAllocatorGetDefault(), [@"google.com" UTF8String]); receivedFlags =
UIImageView *peach2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower2"]];//声明一个UIImageView对象,用来添加图片 peach2.alpha = 0.8;//设置该view的alpha为0.5,半透明的 int xx = round(random()%2000);//随机得到该图片
述一下实现过程: • 首先创建一个项目,名字叫:ipad_webwiew • 利用Interface Builder添加一个UIWebView,然后和相应的代码相关联 • 添加QuartzCore.framework 代码实现: 头文件: #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> @interface
typedef enum { NETWORK_TYPE_NONE= 0, NETWORK_TYPE_WIFI= 1, NETWORK_TYPE_3G= 2, NETWORK_TYPE_2G= 3, }NETWORK_TYPE; 然后通过获取手机信号栏上面的网络类型的标志 + (int)dataNetworkTypeFromStatusBar { UIApplication *app = [UIAp
1、图片的压缩 封装类方法 + (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize { // Create a graphics image context UIGraphicsBeginImageContext(newSize); // Tell the old image to draw in
- (NSString *)calculateWeek:(NSDate *)date{ //计算week数 NSCalendar * myCalendar = [NSCalendar currentCalendar]; myCalendar.timeZone = [NSTimeZone systemTimeZone]; NSInteger week = [[myCalendar component
头文件————————————————————————————— @interface JRUploadRequest : NSMutableURLRequest //初始化方法 + (JRUploadRequest *)uploadRequestWithPath:(NSString *)path; - (JRUploadRequest *)initWithPath:(NSString *)pat
// 调用系统API发送短信 - (void)didClickSendMessageButtonAction{ if ([MFMessageComposeViewController canSendText] == YES) { MFMessageComposeViewController *messageVC = [[MFMessageComposeViewController alloc] i
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; if (device.torchMode == AVCaptureTorchModeOff) { // Create an AV session AVCaptureSession *session = [[AVCaptur
NSLog(@"HostName: %@", [[NSProcessInfo processInfo] hostName]); //globallyUniqueString 唯一的标示符,每次调用都会不一样,可以用作一些临时缓存文件的名字 NSLog(@"GlobalUniqueString: %@", [[NSProcessInfo processInfo] globallyUniqueStri
void *bitmapData; //内存空间的指针,该内存空间的大小等于图像使用RGB通道所占用的字节数。 static CGContextRef CreateRGBABitmapContext (CGImageRef inImage) { CGContextRef context = NULL; CGColorSpaceRef colorSpace; int bitmapByteCount;
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //使用图片初始化背景色 self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage ima
iPhone API已经提供了系统写邮件界面的接口,使用MFMailComposeViewController,用来显示界面. 项目中需要添加MessageUi.framework。头文件加入MFMailComposeViewControllerDelegate。#import <MessageUI/MessageUI.h> sendMailViewController.m文件的实现: - (vo
//Import the MessageUI Framework into your project and //#import the header file into the “.h” file of your controller //where you want to open the In-App SMS sheet. -(IBAction) sendInAppSMS:(id) send
/////// 自适应屏幕 _imageViewPics.contentMode = UIViewContentModeScaleAspectFit; _imageViewPics.autoresizesSubviews = YES; _imageViewPics.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAut
提到从摄像头/相册获取图片是面向终端用户的,由用户去浏览并选择图片为程序使用。在这里,我们需要过UIImagePickerController类来和用户交互。 使用UIImagePickerController和用户交互,我们需要实现2个协议<UIImagePickerControllerDelegate,UINavigationControllerDelegate>。 View Code 代码如