【【转】iOS开发-文件管理(一)】教程文章相关的互联网学习教程文章

iOS开发之自定义输入框(利用UITextField及UITextView)【代码】【图】

drawRect的工作原理:首先苹果是不推荐我们直接使用drawRect进行工作的,直接调用他也是没有任何效果的。苹果要求我们调用UIView类中的setNeedsDisplay方法,则程序会自动调用drawRect方法进行重绘。(调用setNeedsDisplay会自动调用drawRect)。在UIView中,重写drawRect: (CGRect) aRect方法,可以自己定义想要画的图案.且此方法一般情况下只会画一次.也就是说这个drawRect方法一般情况下只会被调用一次。当某些情况下想要手动重画这...

【iOS开发-110】MapKit框架的主要类MKMapView以及代理方法,大头针的使用addAnnotation

#import "ViewController.h" #import <MapKit/MapKit.h> #import <CoreLocation/CoreLocation.h>@interface ViewController ()<MKMapViewDelegate> @property(nonatomic,strong) CLLocationManager *locMgr; @property (weak, nonatomic) IBOutlet MKMapView *mapView; @end@implementation ViewController-(CLLocationManager *)locMgr{if (_locMgr==nil) {_locMgr=[[CLLocationManager alloc]init];}return _locMgr; }- (void)vi...

iOS开发Swift篇—(十)方法【代码】

iOS开发Swift篇—(十)方法一、简单说明跟其他面向对象语言一样,Swift中的方法可以分为2大类:(1)实例方法(Instance Methods)  在OC中,实例方法以减号(-)开头(2)类型方法(Type Methods)  在OC中,类型方法以加号(+)开头 二、实例方法1.什么是实例方法?实例方法:就是只能用对象实例调用的方法,也可以称为“对象方法”实例方法的语法跟函数基本一样2.代码示例:1class Dog { 2 func run() { 3 prin...

ios开发之猜数字游戏

// // main.m // 猜数 //#import <Foundation/Foundation.h> #import "Guess.h"int main(int argc, const char * argv[]) {Guess * number = [[Guess alloc]init];NSLog(@"请输入您所猜的数字");int guessNumber;scanf("%d",&guessNumber);[number guessNumber:guessNumber];//NSLog(@"%d",number->_guessNumber);return 0; } #import <Foundation/Foundation.h>@interface Guess : NSObject {@publicint _guessNumber; }-(void)...

【iOS开发-8】UIButton类型属性简单归纳以及自定义按钮的设置

(1)UIButton类继承自UIControl,而UIControl继承自UIView,因为UIView就是个矩形区域,所以UIButton实例化的对象其实都是一个矩形,虽然有各种圆角、增加联系人、信息按钮等等,给它们加个背景它们就现形成矩形了,而且它们有个frame属性,这就是设置位置和矩形框的。(2)UIButton创建一个按钮不用实例化,也就是不用alloc和init,而是直接调用内置的几个工厂方法即可,这一点和UILabel *label1=[[UILabel alloc]init]不同,而且...

iOS开发百问(9)

101、编译错误:ld: library notfound for -lPods当项目中使用了 cocoaPods 时,经常出现此错误(通常是 release 的时候)。这是由于 pod install 后,cocoaPods 会创建一个新的 workspace。你必须关闭项目并重新打开。问题即可解决。102、为什么 iOS 的时间总是比真实时间慢8小时 例如,一个北京时间"2014-4-4 22:00"(字符串),需要转换成 NSDate。字符串转换成 NSDate 一般是通过 NSDateFormatter 进行的。而在 iOS 上 NSDate ...

iOS开发百问(10)

121、如何将字典/数组转换为字符串?NSString* id2json(id dicOrArr){ NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dicOrArr options:NSJSONWritingPrettyPrinted // Pass 0 if you dont care about thereadability of the generated string error:&error]; if (! jsonData) { DLog(@"Got an error:%@", error); return nil; } else { NSString *jsonString =[[NSString alloc] initWithData:jso...

iOS开发百问(11)

131、如何限制ScrollView在某个方向上不可滚动?例如,要限制x方向上不可滚动,可以实现UIScrollViewDelegate协议方法:func scrollViewDidScroll(scrollView: UIScrollView) { ifabs(scrollView.contentOffset.x) > 0 { scrollView.contentOffset= CGPointMake(0, scrollView.contentOffset.y) } }132、如何在Swift Framework目标中导入O-C框架以BmobSDK 为例(CommonCrypto等C/O-C框架也是一样的),当你将BmobSDK添加到Link Bin...

iOS开发百问(1)

1、设置 ImagePicker 的大小ImagePicker 在 Popover Controller 总是以默认大小显示,设置 popoverContentSize 属性似乎无用。解决办法是将ImagePicker “包含”到一个定制的 ViewController 中,然后再 presentPopover 这个 ViewController :UIViewController *containerController = [[UIViewController alloc] init]; containerController.contentSizeForViewInPopover = CGSizeMake(600,self.view.frame.size.height); [conta...

iOS开发百问(2)

11、无法调试设备“Error launching remote program: failed to get the task forprocess 6405.”ad-hoc Profile不支持调试。改为development profile。12、OTA无法下载,提示“无法下载应用程序”.plist文件中的 bundle-identifier写错了(或者包含中文字符),比如:<key>bundle-identifier</key> <string>com.xxx.--APN--</string>其中的com.xxx.—APN—中包含中文(“--”),应改为英文。或者签名证书是无效的。请在Orgnizer中检...

iOS开发百问(3)

22、解决 messagesent to deallocated instance 0x52cc690 错误当试图对某个对象进行赋值操作的时候出现这个错误,如:tfContent.text=bodyText;此时,你可以打开NSZombieEnable选项,则console会有如下输出:***-[CFString _isNaturallyRTL]: message sent to deallocated instance 0x52cc690 说明_isNaturallyRTL消息被发送给了一个已经释放了的对象。从上面的语句看,可能是这两个对象:tfContent、bodyText。你可以打印tfConte...

iOS开发百问(4)

32、UIImage+Scale缩放图片UIImage可以加载图片,但是我们想要得到一张缩小或放大的图片,利用UIImage不能做到,下面我们添加一个UIImage的分类,用来实现UIImage中图片的放大和缩小。首先,创建一个UIImage+Scale类。然后,实现该类的方法:#import <UIKit/UIKit.h> @interface UIImage (scale) -(UIImage*)scaleToSize:(CGSize)size; @end #import "UIImage+Scale.h" @implementation UIImage (scale) -(UIImage*)scaleToSize:(C...

iOS开发百问(5)【图】

42、 警告:Multiplebuild commands for output filetarget引用了名字重复的资源找到当前的target,展开之后,找到CopyBundle Resources栏目,然后在里面找到重复名字的资源,删除不要的那个即可43、签名错误:Provisioningprofile cant be found在Xcode中当你在更新了你得证书而再重新编译你的程序,真机调试一直会出现Code Sign error: Provisioning profile ‘XXXX’ cant be found是不是会另你很恼火。下面说说解决方法,让你很...

iOS开发百问(6)

61、警告“addexplicit braces to avoid dangling else”所谓“危险的else”是类似这样的代码:if(a== 10) printf("TEN"); else printf("NOT TEN"); a = 100;编译器认为你的else 子句导致语义不清,你到底是什么意思?是无论 a 是否等于10 , if 执行完之后都要将 a 赋值为100,还是只想在 else 子句(即 a 不等于10 的时候)中将 a 赋值为 100?如果是前者,正确的写法应该是:if(a== 10) { printf("TEN"); }else{ printf("NOT TEN"...

iOS开发百问(7)

71、如何让UIWebView的大小符合HTML的内容?在iOS5中,这很简单,设置webview的委托,然后在委托中实现didFinishLoad:方法:-(void)webViewDidFinishLoad:(UIWebView*)webView{ CGSizesize=webView.scrollView.contentSize;//iOS5+ webView.bounds=CGRectMake(0,0,size.width,size.height); }72、窗口中有多个Responder,如何快速释放键盘[[UIApplicationsharedApplication]sendAction:@selector(resignFirstResponder)to:nilfrom:...