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];  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值