??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲综合最新在线,蜜臀av在线播放,91精品国产手机 http://www.aygfsteel.com/mycolby/category/48459.htmlhome zh-cn Sat, 08 Dec 2012 15:24:29 GMT Sat, 08 Dec 2012 15:24:29 GMT 60 IOS使用Reachability实时(g)网l连接状?/title> http://www.aygfsteel.com/mycolby/articles/392464.html剑秋 剑秋 Wed, 05 Dec 2012 03:05:00 GMT http://www.aygfsteel.com/mycolby/articles/392464.html http://www.aygfsteel.com/mycolby/comments/392464.html http://www.aygfsteel.com/mycolby/articles/392464.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/392464.html http://www.aygfsteel.com/mycolby/services/trackbacks/392464.html //在程序的启动处,开启通知
- (BOOL )application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//.....
// 开启网l状늚监听
[[ NSNotificationCenter defaultCenter] addObserver: self
selector : @selector ( reachabilityChanged:)
name : kReachabilityChangedNotification
object : nil ];
hostReach = [[ Reachability reachabilityWithHostName: @"www.google.com" ] retain ];//可以以多UŞ式初始化
[ hostReach startNotifier]; //开始监??x)启动一个run loop
[ self updateInterfaceWithReachability: hostReach ];
//.....
}
// q接改变
- (void ) reachabilityChanged: (NSNotification * )note
{
Reachability * curReach = [note object ];
NSParameterAssert ([curReach isKindOfClass : [Reachability class ]]);
[ self updateInterfaceWithReachability: curReach];
}
//处理q接改变后的情况
- (void ) updateInterfaceWithReachability: (Reachability *) curReach
{
//对连接改变做出响应的处理动作?/p>
NetworkStatus status = [curReach currentReachabilityStatus];
if (status == NotReachable ) { //没有q接到网l就弹出提实?/p>
UIAlertView *alert = [[ UIAlertView alloc ] initWithTitle : @"My App Name"
message :@"NotReachable"
delegate :nil
cancelButtonTitle :@"YES" otherButtonTitles :nil ];
[alert show ];
[alert release ];
}
}
]]>W三方苹果开发库之ASIHTTPRequest(转蝲) http://www.aygfsteel.com/mycolby/articles/387353.html剑秋 剑秋 Sun, 09 Sep 2012 14:32:00 GMT http://www.aygfsteel.com/mycolby/articles/387353.html http://www.aygfsteel.com/mycolby/comments/387353.html http://www.aygfsteel.com/mycolby/articles/387353.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/387353.html http://www.aygfsteel.com/mycolby/services/trackbacks/387353.html 阅读全文 ]]> IOS的框?转蝲) http://www.aygfsteel.com/mycolby/articles/383190.html剑秋 剑秋 Mon, 16 Jul 2012 02:13:00 GMT http://www.aygfsteel.com/mycolby/articles/383190.html http://www.aygfsteel.com/mycolby/comments/383190.html http://www.aygfsteel.com/mycolby/articles/383190.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/383190.html http://www.aygfsteel.com/mycolby/services/trackbacks/383190.html 本附录介liOSpȝ包含的框Ӟ它们为编写iOSq_的Y件提供必要的接口。下面的表格可能地列出框架中的cR方法、函数、类型以?qing)常量用的关键前缀Q请避免在?zhn)的符号名UC使用q些前缀?/p>讑֤中的框架 表B-1描述iOS讑֤提供的框Ӟ它们位于<Xcode> /Platforms/iPhoneOS.platform/Developer/SDKs/ <iOS_SDK> /System/Library/Frameworks 目录。\径中?lt;Xcode>表示Xcode的安装目录, <iOS_SDK>则表C目标SDK版本。表中标题ؓ(f)“最先引?#8221;的那一列表C首ơ引入相x架的的iOSpȝ版本?/p>
模拟器的框架 虽然~写代码应该面向讑֤框架Q但是在试的过E中Q?zhn)也需要针Ҏ(gu)拟器~译代码。设备和模拟器的框架E有区别。模拟器几个Mac OS X框架作ؓ(f)其自w实现的一部分。另外,׃pȝ的限Ӟ讑֤框架的确切接口有可能和模拟器框架E有不同。如果?zhn)需要这些框架的列表以及(qing)讑֤和模拟器框架之间的差异信息,h?a target="_top" style="color: #3366cc; text-decoration: none; ">iOS 开发指?/a>?/p>pȝ?/span>h意,iOSpȝ可能没有Core OS和Core Services层某些特D的库打包成框架Q而是其作ؓ(f)动态库攑֜pȝ?br />/usr/lib 目录。动态共享库通过 .dylib 扩展名标识,其相应的头文件位?br />/usr/include 目录?/p>
所有版本的iPhone SDK都包含一份安装在pȝ的动态共享库本地副本。这些副本被安装在?zhn)的开发系l,(zhn)可以从XCode工程q行链接。如果?zhn)需要查看某个版本的动态库列表Q请查看<Xcode> /Platforms/iPhoneOS.platform/Developer/SDKs/ <iOS_SDK> /usr/lib 。在q个路径中,<Xcode>表示Xcode的安装目录,<iOS_SDK>表示(zhn)当时正在用某个版本的SDK。D个例子,iOS 3.0 SDK的动态库位于 /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib 目录Q相应的头文件则位于 /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include 目录?/p>
iOS使用W号链接来指向程序库的最q版本。在链接某个动态共享库的时候,请用符号链接而不要用动态库特定版本链接。因为在来的iOS版本中,库的版本可能?x)发生改变。如果?zhn)的Y件连接到某个特定的版本,而那个版本可能已l不存在于用L(fng)pȝ当中Q那׃(x)出问题?/p>
]]>
改变控gframe的动L?/title> http://www.aygfsteel.com/mycolby/articles/368156.html剑秋 剑秋 Mon, 09 Jan 2012 09:03:00 GMT http://www.aygfsteel.com/mycolby/articles/368156.html http://www.aygfsteel.com/mycolby/comments/368156.html http://www.aygfsteel.com/mycolby/articles/368156.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/368156.html http://www.aygfsteel.com/mycolby/services/trackbacks/368156.html
[UIView beginAnimations:nil context:self]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:0.4f]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; _tableView.frame = CGRectMake(10, 19, 300, 367); [UIView commitAnimations]; ]]> 修改UISearchBar的键盘ؓ(f)中文样式 http://www.aygfsteel.com/mycolby/articles/365744.html剑秋 剑秋 Wed, 07 Dec 2011 05:29:00 GMT http://www.aygfsteel.com/mycolby/articles/365744.html http://www.aygfsteel.com/mycolby/comments/365744.html http://www.aygfsteel.com/mycolby/articles/365744.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/365744.html http://www.aygfsteel.com/mycolby/services/trackbacks/365744.html if ([searchBarSubview conformsToProtocol:@protocol(UITextInputTraits)]) { @try { // set style of keyboard [(UITextField *)searchBarSubview setKeyboardAppearance:UIKeyboardAppearanceAlert]; // always force return key to be enabled [(UITextField *)searchBarSubview setEnablesReturnKeyAutomatically:NO]; } @catch (NSException * e) { // ignore exception } } } ]]> iphone开发的一些小技?? http://www.aygfsteel.com/mycolby/articles/362013.html剑秋 剑秋 Tue, 25 Oct 2011 07:35:00 GMT http://www.aygfsteel.com/mycolby/articles/362013.html http://www.aygfsteel.com/mycolby/comments/362013.html http://www.aygfsteel.com/mycolby/articles/362013.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/362013.html http://www.aygfsteel.com/mycolby/services/trackbacks/362013.html 去除nsstring中的I格NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet ]; NSString * username = [mUsernameField stringValue]; username = [username stringByTrimmingCharactersInSet :whitespace]; 让覆盖在下面层的视图接受触摸事g searchImage.exclusiveTouch = YES;//W一?/span>searchImage.userInteractionEnabled = NO; myMapView.exclusiveTouch = NO;//W二?/span>myMapView.userInteractionEnabled = YES; 防止屏幕暗掉锁屏 [ [ UIApplication sharedApplication ] setIdleTimerDisabled: YES ] ;状态栏的网l活动风火轮是否旋{ [UIApplication sharedApplication].networkActivityIndicatorVisibleQ默认值是NO?/span>键盘透明 textField.keyboardAppearance = UIKeyboardAppearanceAlert; 截取屏幕囄 //创徏一个基于位囄囑Ş上下文ƈ指定大小为CGSizeMake(200,400) UIGraphicsBeginImageContext(CGSizeMake(200,400)); //renderInContext 呈现接受者及(qing)其子范围到指定的上下?/span>[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; //q回一个基于当前图形上下文的图?/span> UIImage *aImage = UIGraphicsGetImageFromCurrentImageContext(); //U除栈顶的基于当前位囄囑Ş上下?/span>UIGraphicsEndImageContext(); //以png格式q回指定囄的数?/span>imageData = UIImagePNGRepresentation(aImage); 更改cell选中的背?/span>UIView *myview = [[UIView alloc] init]; myview.frame = CGRectMake(0, 0, 320, 47); myview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"0006.png"]]; cell.selectedBackgroundView = myview; 从本地加载图?/span>NSString *boundle = [[NSBundle mainBundle] resourcePath]; [web1
loadHTMLString:[NSString stringWithFormat:@"<img
src='http://fei263.blog.163.com/blog/0001.png'/>"] baseURL:[NSURL
fileURLWithPath:boundle]]; View自己调用自己的方? [self performSelector:@selector(loginToNext) withObject:nil afterDelay:2];//黄色Dؓ(f)Ҏ(gu)?和gq几U执? 动画:一个接一个地昄一pd的图?/span>NSArray
*myImages = [NSArray arrayWithObjects: [UIImage
imageNamed:@"myImage1.png"], [UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"], [UIImage
imageNamed:@"myImage4.gif"], nil]; UIImageView *myAnimatedView = [UIImageView alloc]; [myAnimatedView initWithFrame:[self bounds]]; myAnimatedView.animationImages = myImages; //animationImages属性返回一个存攑֊d片的数组 myAnimatedView.animationDuration = 0.25; //览整个囄一ơ所用的旉 myAnimatedView.animationRepeatCount = 0; // 0 = loops forever 动画重复ơ数 [myAnimatedView startAnimating]; [self addSubview:myAnimatedView]; [myAnimatedView release]; ]]> UITableViewCell最x变背景色的方?/title> http://www.aygfsteel.com/mycolby/articles/361872.html剑秋 剑秋 Mon, 24 Oct 2011 03:28:00 GMT http://www.aygfsteel.com/mycolby/articles/361872.html http://www.aygfsteel.com/mycolby/comments/361872.html http://www.aygfsteel.com/mycolby/articles/361872.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/361872.html http://www.aygfsteel.com/mycolby/services/trackbacks/361872.html - ( UITableViewCell * ) tableView: ( UITableView * ) tableView cellForRowAtIndexPath: ( NSIndexPath * ) indexPath { static NSString * cellIdentifier = @"CellIdentifier" ; UITableViewCell * cell = [ tableView dequeueReusableCellWithIdentifier: cellIdentifier] ; if ( ! cell) { cell = [ [ [ UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: cellIdentifier] autorelease] ; } cell.textLabel .text = [ NSString stringWithFormat: @"Line: %d" , indexPath.row ] ; cell.textLabel .backgroundColor = [ UIColor clearColor] ; UIView * backgrdView = [ [ UIView alloc] initWithFrame: cell.frame ] ; backgrdView.backgroundColor = [ UIColor blueColor] ; cell.backgroundView = backgrdView; [ backgrdView release] ; return cell; } ]]> UIWebView的一些技?/title> http://www.aygfsteel.com/mycolby/articles/360256.html剑秋 剑秋 Sun, 09 Oct 2011 03:33:00 GMT http://www.aygfsteel.com/mycolby/articles/360256.html http://www.aygfsteel.com/mycolby/comments/360256.html http://www.aygfsteel.com/mycolby/articles/360256.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/360256.html http://www.aygfsteel.com/mycolby/services/trackbacks/360256.html
UIWebView加蝲的html里,加蝲工程文g的图?/span>
W一U方法:(x)
在info.plist里面定义个URL schema比如?youappQ那么\径就写成youapp://test.png
可以参照http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html ?/p>
W二U方法:(x)
NSString *htmlString = @"<html><head><body><img
src=\"logo.png\"><body></head></html>"; NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; [self.myWebView loadHTMLString:htmlString baseURL:baseURL];
q个html是你自己写的一个本地html文gQ用来布|UIWebView界面。里面用到的囄可以是工E文仉面的Q也可以是网l上的。给出Url?wbr>
解决在UIWebView中加载图片时出现延迟现象的做?/span> 文字和图片同时显C:(x)
NSString* showHtml = @"<html><head></head><body><img src='data:image/jpg;base64,%@'/> <p>here is show a picture.</p></body></html>"; NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"www.abc.com/img/img1.jpg"]]; NSString* imageString = [imageData base64Encoding]; UIWebView* webView = [UIWebView alloc]; [webView loadHTMLString:[NSString stringWithFormat:showHtml, imageString] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]]Q?//以下把该UIWebView昄出来的代码略 _体的地方就是通过base64来实现的地方Q我们这里显C的是jpg格式的图片,因此在img标签的src属性里面写的是“src=’data:image/jpg ;base64,%@’”Q而如果是其他格式的图片的话记得把对应的地方给改一?/p>
<img src="
]]> iphone开发的一些小技??(正则表达式判断url) http://www.aygfsteel.com/mycolby/articles/356849.html剑秋 剑秋 Fri, 19 Aug 2011 04:59:00 GMT http://www.aygfsteel.com/mycolby/articles/356849.html http://www.aygfsteel.com/mycolby/comments/356849.html http://www.aygfsteel.com/mycolby/articles/356849.html#Feedback 1 http://www.aygfsteel.com/mycolby/comments/commentRss/356849.html http://www.aygfsteel.com/mycolby/services/trackbacks/356849.html NSString *a = @"http+:[^\\s]*"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", a]; BOOL checked = [emailTest evaluateWithObject:urlString]; 下面是判断url合法q抽取合法的urlQ?br /> //NSRegularExpressionc里面调用表辄Ҏ(gu)需要传递一个NSError的参数。下面定义一?br /> NSError *error; //http+:[^\\s]* q个表达式是(g)一个网址的?br /> NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"http+:[^\\s]*" options:0 error:&error]; if (regex != nil) { NSTextCheckingResult *firstMatch=[regex firstMatchInString:urlString options:0 range:NSMakeRange(0, [urlString length])]; NSTextCheckingResult *firstMacth = [regex ] if (firstMatch) { NSRange resultRange = [firstMatch rangeAtIndex:0]; //从urlString当中截取数据 NSString *result=[urlString substringWithRange:resultRange]; //输出l果 NSLog(@"%@",result); }else { NSLog(@"no result"); } } ]]> 为UIToolBar工具条添加各U各L(fng)UIBbarButtonItem(转蝲) http://www.aygfsteel.com/mycolby/articles/356608.html剑秋 剑秋 Tue, 16 Aug 2011 02:09:00 GMT http://www.aygfsteel.com/mycolby/articles/356608.html http://www.aygfsteel.com/mycolby/comments/356608.html http://www.aygfsteel.com/mycolby/articles/356608.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/356608.html http://www.aygfsteel.com/mycolby/services/trackbacks/356608.html (转蝲请保留此文字Q本文来?[iphone开发私房菜_2_] 为UIToolBar工具条添加各U各L(fng)UIBbarButtonItem http://blog.csdn.net/ipromiseu/archive/2010/12/16/6080689.aspx ] write by Gray.Luo guohui.great@gmail.com)
1.首先Q我们看一下UIBbarButtonItem有哪些初始化Ҏ(gu)Q这也可以看出,它可以被定义Z么东东,然后加到UIToolBar上面厅R?/p>
Ҏ(gu)SDK的文档,我们可以发现UIBbarButtonItem有如下几U初始化的方法:(x)
-initWithTitle
-initWithImage
-initWithBarButtonSystemItem
-initWithCustomView
W?U方法就是我们添加各U作料的接口Q所以今天的主角其它也是它?/p>
2.在UIToolBar上面dTitle
UIToolbar *myToolBar = [[UIToolbar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)]; NSMutableArray *myToolBarItems = [NSMutableArray array]; [myToolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"myTile" style:UIBarButtonItemStylePlain target:self action:@selector(action)] autorelease]]; [myToolBar setItems:myToolBarItems animated:YES]; [myToolBar release]; [myToolBarItems];
setItems传入值或者说items是一个对象数l?/p>
3.在UIToolBar上面dimage
[myToolBarItems addObject:[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"myImage.png" ] style:UIBarButtonItemStylePlain target:self action:@selector(action)]];
4.在UIToolBar上面dSystemItem
[myToolBarItems addObject:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(action)] autorelease]];
Note:
initWithBarButtonSystemItem初始化:(x)
- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action
Defines system defaults for commonly used items.
typedef enum { UIBarButtonSystemItemDone, UIBarButtonSystemItemCancel, UIBarButtonSystemItemEdit, UIBarButtonSystemItemSave, UIBarButtonSystemItemAdd, UIBarButtonSystemItemFlexibleSpace, UIBarButtonSystemItemFixedSpace, UIBarButtonSystemItemCompose, UIBarButtonSystemItemReply, UIBarButtonSystemItemAction, UIBarButtonSystemItemOrganize, UIBarButtonSystemItemBookmarks, UIBarButtonSystemItemSearch, UIBarButtonSystemItemRefresh, UIBarButtonSystemItemStop, UIBarButtonSystemItemCamera, UIBarButtonSystemItemTrash, UIBarButtonSystemItemPlay, UIBarButtonSystemItemPause, UIBarButtonSystemItemRewind, UIBarButtonSystemItemFastForward, UIBarButtonSystemItemUndo, UIBarButtonSystemItemRedo, } UIBarButtonSystemItem;
5.在UIToolBar上面d其它各种控g,最自由意义Q最有意思的Q我把它攑֜最后来讌Ӏ我们用initWithCustomView来完成,
q里需要看一下initWithCustomView的定义:(x)
- (id)initWithCustomView:(UIView *)customView
可以看出Q它的参数是一个VIEWQ所以我们给它的配料要正哦才行哦,否则Q你q着旉DIDADIDA的流失吧.
A>加一个开关switchQ?/p>
[myToolBarItems addObject:[[[UIBarButtonItem alloc] initWithCustomView:[[[UISwitch alloc] init] autorelease]] autorelease]];
B>加一个按钮UIBarButtonItem
UIBarButtonItem *myButton = [[[UIBarButtonItem alloc] initWithTitle:@"myButton" style:UIBarButtonItemStyleBordered target:self action:@selector(action)]autorelease]; get1Button.width = 50; [myToolBarItems addObject:myButton];
C>加一个文本Label
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(40.0f, 20.0f, 45.0f, 10.0f)]; myLabel.font=[UIFont systemFontOfSize:10]; UIBarButtonItem *myButtonItem = [[UIBarButtonItem alloc]initWithCustomView:myLabel]; [myToolBarItems addObject: myButtonItem]; [mylabel release]; [myButtonItem release];
D>加一个进度条UIProgressView
UIProgressView *myProgress = [[UIProgressView alloc] initWithFrame:CGRectMake(65.0f, 20.0f, 90.0f, 10.0f)]; UIBarButtonItem *myButtonItem = [[UIBarButtonItem alloc]initWithCustomView:myProgress]; [myToolBarItems addObject: myButtonItem]; [myProgress release]; [myButtonItem release];
可以加用initWithCustomView制作各种buttonQ这里就不在q里一个一个在加了(jin)。我想你应该也已l掌握了(jin)如何d各种buttonItem的方法了(jin)?/p>
]]> iphone开发的一些小技??(关键字:(x)document的\径及(qing)路径下所有的资源,切割囄) http://www.aygfsteel.com/mycolby/articles/356575.html剑秋 剑秋 Mon, 15 Aug 2011 08:38:00 GMT http://www.aygfsteel.com/mycolby/articles/356575.html http://www.aygfsteel.com/mycolby/comments/356575.html http://www.aygfsteel.com/mycolby/articles/356575.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/356575.html http://www.aygfsteel.com/mycolby/services/trackbacks/356575.html iPhone和symbian 3rd一P?x)?f)每一个应用程序生成一个私有目录,q个目录位于/Users/sundfsun2009/Library/Application
Support/iPhone
Simulator/User/Applications下,q即生成一个数字字母串作ؓ(f)目录名,在每一ơ应用程序启动时Q这个字母数字串都是不同于上一ơ?/p>
通常使用Documents目录q行数据持久化的保存Q而这个Documents目录可以通过 NSSearchPathForDirectoriesInDomainsQNSDocumentDirectoryQNSUserdomainMaskQYESQ?
得到Q代码如下:(x)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];
// NSString *path = [documentsDirectory stringByAppendingPathComponent:@"aa.plist"];
NSLog(@"path: %@",path);
打印l果如下Q?/p>
path: /Users/apple/Library/Application Support/iPhone Simulator/4.3/Applications/550AF26D-174B-42E6-881B-B7499FAA32B7/Documents
而这个目录还可以通过 NSHomeDirectory()来得刎ͼ代码如下Q?/p>
NSString *destPath = NSHomeDirectory(); NSLog(@"path: %@",destPath); //destPath = [destPath stringByAppendingPathComponent: @"Documents"]; //NSString *xmlpath = [destPath stringByAppendingPathComponent: @"menu/menu.xml"];
打印l果如下Q?br />
path: /Users/apple/Library/Application Support/iPhone Simulator/4.2/Applications/6F4BC466-C5D6-440C-BAAC-BE20FA468C61
看看两者打印出来的l果Q我们可以看?gu)两种?gu)的不同?/p>
2. 览document下所有图片资?/p>
#define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] NSArray *fileList = [[[NSFileManager defaultManager] directoryContentsAtPath:DOCUMENTS_FOLDER] pathsMatchingExtensions:[NSArray arrayWithObject:@"png"]] ;
3. 得到囄中的某一部分Q?br />
UIImage *image = [UIImage imageNamed :filename];
CGImageRef imageRef = image.CGImage ;
CGRect rect = CGRectMake (origin.x , origin.y ,size.width , size.height );
CGImageRef imageRefRect = CGImageCreateWithImageInRect (imageRef, rect);
UIImage *imageRect = [[UIImage alloc ] initWithCGImage :imageRefRect];
]]>iphone开发的一些小技?一)(关键字:(x)除去UITableView的边框和划动删除Q同步请求及(qing)异步h) http://www.aygfsteel.com/mycolby/articles/356299.html剑秋 剑秋 Thu, 11 Aug 2011 05:48:00 GMT http://www.aygfsteel.com/mycolby/articles/356299.html http://www.aygfsteel.com/mycolby/comments/356299.html http://www.aygfsteel.com/mycolby/articles/356299.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/356299.html http://www.aygfsteel.com/mycolby/services/trackbacks/356299.html 1. 如何除去UITableViewStyleGroupcd的UITableView的边框:(x) UITableViewStylePlaincd的UITableView去除Ҏ(gu)U有直接的属性方法:(x)
separatorStyle = UITableViewCellSeparatorStyleNone;
但在UITableViewStyleGroupedcd的UITableView中,该方法无?br /> 如何去除Ҏ(gu)U呢Q答案很单:(x)
separatorColor=[UIColor clearColor];
2. UITableView划动删除的实?/strong>
需要实C面两个方?/p>
- ( BOOL )tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void )tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath: (NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[dataArray removeObjectAtIndex:indexPath.row];
[testTableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
}
}
3. NSURLConnection同步Q异步与SSL 同步h NSURL *url=[[NSURL alloc]initWithString:urlString]; NSMutableURLRequest *request=[[NSMutableURLRequest alloc]init]; NSError *err=nil; NSData *data=[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&err]; if(data==nil) { //if([err code]) NSLog(@"Code:%d,domain:%@,localizedDesc:%@",[err code], [err domain],[err localizedDescription]); } else { } q种情况Q通过一个静(rn)态方法,hrequest,q种情况下,?x)一直阻塞,{到q回l果Q简单易?br /> 异步h NSURL *url=[[NSURL alloc]initWithString:urlString]; NSMutableURLRequest *request=[[NSMutableURLRequest alloc]init]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [url release]; [request release]; if(connection) { receivedData = [[NSMutableData data] retain]; NSLog(@"intial done!"); } else { NSLog(@"sorry"); } 通过一个delegate来做数据的下载以?qing)Request的接受等{消息,此处delegate:selfQ所以需要本cdC些方法,q且定义receivedData做数据的接受 基本上要实现下面节歌Ҏ(gu) - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"get the whole response"); [receivedData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"get some data"); [receivedData appendData:data]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [connection release]; NSLog(@"Connection failed! Error - %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSErrorFailingURLStringKey]); } 基本上这样就搞定?jin)!Q! 但是异步模式下带来了(jin)一个新的问题,很多情况下,|络h不在ȝE,或者界面等待网l结果,不在ȝE的时候,调用U程如果生命周期o(w)verQ下面这些可能都没有调用刎ͼD得不到想要得效果Q所以需要在NSURLConnectionh后面加点东西来阻?br /> while(!finished) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } 好了(jin)Q现在我们看看SSL的问题,在NSURLConnnection本来有方法可以蟩qssl(g)查,可惜被apple无情的私有了(jin)Q所以同步的数据h肯定不行?jin),看看文档Q只能通过异步delegate的方式了(jin) - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; } - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) if ([trustedHosts containsObject:challenge.protectionSpace.host]) [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; } W一个方法会(x)Ҏ(gu)你的URL来判断是否需要做认证 W二个方法是认证的过E,if ([trustedHosts containsObject:challenge.protectionSpace.host])Q这行代码注释掉Q就可以自动所有SSL通过Q否则,你可以加一些Trust的hostsQ其他的不通过p?jin)!Q!
]]> 关于NSRang的一些用?/title> http://www.aygfsteel.com/mycolby/articles/356027.html剑秋 剑秋 Mon, 08 Aug 2011 08:13:00 GMT http://www.aygfsteel.com/mycolby/articles/356027.html http://www.aygfsteel.com/mycolby/comments/356027.html http://www.aygfsteel.com/mycolby/articles/356027.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/356027.html http://www.aygfsteel.com/mycolby/services/trackbacks/356027.html NSRang是一个结构体Q有两个属性:(x) location和length
location:是一个烦(ch)引,该烦(ch)引标识的是在Q字W串中捡索到Q字W串的烦(ch)引;
length:?/span>捡烦(ch)的字W串的长度,卻I字符串的长度Q?/span>
下面是随手写的一个简单的例子Q?/span>
NSString *ns = @"aabbcc?eeff" ;
NSRange rng = [ns rangeOfString : @"?" ];
NSInteger lo = rng. location ;
NSString *ts = [ns substringToIndex :lo];
NSLog ( @"substringToIndex: %@" ,ts);
NSString *fs = [ns substringFromIndex :(lo+ 1 )];
NSLog ( @"substringFromIndex: %@" ,fs);
打印的结果:(x) 2011-08-08 15:48:36.068 wCityFW[2375:207] substringToIndex: aabbcc
2011-08-08 15:48:36.069 wCityFW[2375:207] substringFromIndex: eeff
由此我们可以看出 substringToIndexQ是从将要检索的字符Ԍ 卻I字符串的首字W到(g)索到Q字W串的烦(ch)引的一D子字符Ԍ
substringFromIndexQ是从检索到Q字W串的烦(ch)引到被检索的字符串末字符的一D字W串?/strong>
]]> iphone 代码片断 http://www.aygfsteel.com/mycolby/articles/354859.html剑秋 剑秋 Fri, 22 Jul 2011 08:27:00 GMT http://www.aygfsteel.com/mycolby/articles/354859.html http://www.aygfsteel.com/mycolby/comments/354859.html http://www.aygfsteel.com/mycolby/articles/354859.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/354859.html http://www.aygfsteel.com/mycolby/services/trackbacks/354859.html - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.tag = 1;
label.lineBreakMode = UILineBreakModeWordWrap;
label.highlightedTextColor = [UIColor whiteColor];
label.numberOfLines = 0;
label.opaque = NO; // 选中Opaque表示视图后面的Q何内定w不应该绘?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Lucida Grande', Geneva, Arial, Verdana, sans-serif; " />
label.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:label];
[label release];
}
UILabel *label = (UILabel *)[cell viewWithTag:1];
NSString *text;
text = [textArray objectAtIndex:indexPath.row];
CGRect cellFrame = [cell frame];
cellFrame.origin = CGPointMake(0, 0);
label.text = text;
CGRect rect = CGRectInset(cellFrame, 2, 2);
label.frame = rect;
[label sizeToFit];
if (label.frame.size.height > 46) {
cellFrame.size.height = 50 + label.frame.size.height - 46;
}
else {
cellFrame.size.height = 50;
}
[cell setFrame:cellFrame];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
return cell.frame.size.height;
} ]]>Sizes of iPhone UI Elements[转蝲] http://www.aygfsteel.com/mycolby/articles/350579.html剑秋 剑秋 Thu, 19 May 2011 03:16:00 GMT http://www.aygfsteel.com/mycolby/articles/350579.html http://www.aygfsteel.com/mycolby/comments/350579.html http://www.aygfsteel.com/mycolby/articles/350579.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/350579.html http://www.aygfsteel.com/mycolby/services/trackbacks/350579.html ]]>iPhone sdk的学?fn)笔?/title> http://www.aygfsteel.com/mycolby/articles/349516.html剑秋 剑秋 Wed, 04 May 2011 09:23:00 GMT http://www.aygfsteel.com/mycolby/articles/349516.html http://www.aygfsteel.com/mycolby/comments/349516.html http://www.aygfsteel.com/mycolby/articles/349516.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/349516.html http://www.aygfsteel.com/mycolby/services/trackbacks/349516.html
[receiver appendFormat:@"%@",[self.receiverArray objectAtIndex:i]];
2.[self.textfield becomeFirstResponder] ->焦点移到NSTextField上,q时虚拟键盘会(x)出现
[self.textfield resignFirstResponder] ->焦点移出NSTextFieldQ这时虚拟键盘将?x)关?br />
becomeFirstResponder ->焦点移动控件上
resignFirstResponder ->焦点移出控?br />
3.viewWillAppear:
Called when the view is about to made visible. Default does nothing
视图卛_可见时调用。默认情况下不执行Q何操?br />
viewDidAppear:
Called when the view has been fully transitioned onto the screen. Default does nothing
视图已完全过渡到屏幕上时调用
viewWillDisappear:
Called when the view is dismissed, covered or otherwise hidden. Default does nothing
视图被驳回时调用Q覆盖或以其他方式隐藏。默认情况下不执行Q何操?br />
viewDidDisappear:
Called after the view was dismissed, covered or otherwise hidden. Default does nothing
视图被驳回后调用Q覆盖或以其他方式隐藏。默认情况下不执行Q何操?br />
loadView;
This is where subclasses should create their custom view hierarchy if they aren't using a nib. Should never be called directly.
q是当他们没有正在用nib视图面Q子cd?x)创q自定义视囑ֱ。绝不能直接调用?br />
viewDidLoad;
Called
after the view has been loaded. For view controllers created in code,
this is after -loadView. For view controllers unarchived from a nib,
this is after the view is set.
在视囑֊载后被调用,如果是在代码中创建的视图加蝲器,他将?x)在loadViewҎ(gu)后被调用Q如果是从nib视图面输出Q他会(x)在视图设|好 后被调用?br />
]]> iPhone sdk与jdk的对应类Q学?fn)?..陆箋更新Q?/title> http://www.aygfsteel.com/mycolby/articles/349502.html剑秋 剑秋 Wed, 04 May 2011 08:05:00 GMT http://www.aygfsteel.com/mycolby/articles/349502.html http://www.aygfsteel.com/mycolby/comments/349502.html http://www.aygfsteel.com/mycolby/articles/349502.html#Feedback 0 http://www.aygfsteel.com/mycolby/comments/commentRss/349502.html http://www.aygfsteel.com/mycolby/services/trackbacks/349502.html
NSArray(NSMutableArray) -> ArrayList
NSString -> String
NSMutableString -> StringBuffer
NSData(NSMutableData) -> byte[]
]]>
վ֩ģ壺
|
|
|
|
̩ |
|
|
|
˫ |
|
ƽ |
|
|
|
Ҷ |
|
|
ɽ |
¡ |
лͨ |
ƽ |
|
ζ |
|
ɳ |
|
|
ɫ |
Ǩ |
ﴨ |
|
|
ɽ |
|
|
|
ʯ |
ƽ |
|
ˮ |
|