订阅

2010

Jul

29

iPhone开发笔记(一)
文章类别:iPhone开发

1、联机调试时需要修改项目的get info和Targets的get info中的KEY,plist的Bundle identifier值;

2、有Sec类跳转到Third类的方法:
在 Sec.m中添加#import "Third.h";
再添加:

Objective-C代码
  1. - (IBAction)gotoSec:(id) sender{  
  2.     NSString *viewControllerName = @"Third";  
  3.     Third *viewController = [[NSClassFromString(viewControllerName) alloc] initWithNibName:viewControllerName bundle:nil];  
  4.     [self.view addSubview: viewController.view];  
  5. }  

3、让图片滚动:
将uiimageview放在scroll view里面,设置scroll view的插座变量并设置其代理,
加入代 码scrollview.contentSize = CGSizeMake(400,600);

 4、让图片缩放:
在上一个的基础上设置uiimage view的插座变量,在scroll view的属性中调整最大放大和最小缩小的值,加入如下函数(无需调用):

Objective-C代码
  1. -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{  
  2.     if(scrollView==scrollview)  
  3.         return imgview;  
  4.     return FALSE;  
  5. }  

5、函数返回的如果是指针类型则使用自动释放池:return [name autorelease];

6、UIWebView的使用方法:

Objective-C代码
  1. [webview setOpaque:NO];  
  2. [webview setBackgroundColor:[UIColor clearColor]];  
  3. NSString *HTMLData = @"<img src=\"http://image.17173.com/bbs/upload/2006/04/06/1144319556.gif\" alt=\"picture\" width=\"306\"/>";  
  4. [webview loadHTMLString:HTMLData baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];  

7、UIImageView使用web图片:

Objective-C代码
  1. UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3092/2915896504_a88b69c9de.jpg"]]];  

8、UITableViewCell自定义选中背景:

Objective-C代码
  1. cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];  
  2. 字体颜色:  
  3. cell.textLabel.highlightedTextColor = COOKBOOK_PURPLE_COLOR;   

8、Loading的用法:

Objective-C代码
  1. - (void)viewDidLoad {  
  2.     [self.view addSubview:loadingview];  
  3.     [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(loading) userInfo:nil repeats:NO];  
  4.     [super viewDidLoad];  
  5. }  
  6. - (void)loading {  
  7.     [loadingview removeFromSuperview];  
  8. }  

9、输入框点击done返回:

Objective-C代码
  1. 一、self.idinput.returnKeyType = UIReturnKeyDone;  
  2. 二、然后设置按钮的代理;
    三、 
  3. -(BOOL)textFieldShouldReturn:(UITextField *)theTextField {  
  4.     [theTextField resignFirstResponder];  
  5.     return YES;  
  6. }  

10、alert的使用:

Objective-C代码
  1. UIAlertView *alertstart = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Easy",@"Medium",@"Hard",nil];  
  2. [alertstart show];  
  3. //弹出层选择  
  4. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{  
  5.     if(buttonIndex == 0){ //取消  
  6.         stage = 0;  
  7.     }else{  
  8.         if(buttonIndex == 1){ //中等  
  9.             mainstageviewcontroller.gamelevel = 0;  
  10.         }else if(buttonIndex == 2){ //困难  
  11.             mainstageviewcontroller.gamelevel = 1;  
  12.         }else if(buttonIndex == 3){ //取消  
  13.             mainstageviewcontroller.gamelevel = 2;  
  14.         }  
  15.     [alertView release];  
  16. }  

 

标签:iphone
阅读全文>> | 评论(1) | 阅读(221)
相关文章:

iPhone initWithFrame: reuseIdentifier: is deprecated的解決方法 (2010-08-25)

iPhone开发笔记(二) (2010-07-31)

iPhone开发之显示WiFi提示 (2010-07-23)

iPhone开发之全局变量的使用 (2010-07-21)

iPhone开发之UIWebView的使用方法 (2010-07-15)

看看他们的脚印……

踏雪残情

2010-07-29 19:49:31

坐个沙发,已阅!!
我也踩个脚印^_^

闲言碎语
靠,现在的垃圾留言也太智能了吧。 (9月7日)
不要逼我把你加入黑名单,少在这里发广告! (8月17日)
周末回家咯 (8月13日)
文章分类
最近文章
最近评论
日志归档
友情链接
其它功能
随机标签