1、联机调试时需要修改项目的get info和Targets的get info中的KEY,plist的Bundle identifier值;
2、有Sec类跳转到Third类的方法:
在 Sec.m中添加#import "Third.h";
再添加:
Objective-C代码
- - (IBAction)gotoSec:(id) sender{
- NSString *viewControllerName = @"Third" ;
- Third *viewController = [[NSClassFromString(viewControllerName) alloc] initWithNibName:viewControllerName bundle:nil];
- [self.view addSubview: viewController.view];
- }
3、让图片滚动:
将uiimageview放在scroll view里面,设置scroll view的插座变量并设置其代理,
加入代 码scrollview.contentSize = CGSizeMake(400,600);
4、让图片缩放:
在上一个的基础上设置uiimage view的插座变量,在scroll view的属性中调整最大放大和最小缩小的值,加入如下函数(无需调用):
Objective-C代码
- -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
- if (scrollView==scrollview)
- return imgview;
- return FALSE;
- }
5、函数返回的如果是指针类型则使用自动释放池:return [name autorelease];
6、UIWebView的使用方法:
Objective-C代码
- [webview setOpaque:NO];
- [webview setBackgroundColor:[UIColor clearColor]];
- NSString *HTMLData = @"<img src=\"http://image.17173.com/bbs/upload/2006/04/06/1144319556.gif\" alt=\"picture\" width=\"306\"/>" ;
- [webview loadHTMLString:HTMLData baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
7、UIImageView使用web图片:
Objective-C代码
- UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@ "http://farm4.static.flickr.com/3092/2915896504_a88b69c9de.jpg" ]]];
8、UITableViewCell自定义选中背景:
Objective-C代码
- cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@ "cellart.png" ]] autorelease];
- 字体颜色:
- cell.textLabel.highlightedTextColor = COOKBOOK_PURPLE_COLOR;
8、Loading的用法:
Objective-C代码
- - ( void )viewDidLoad {
- [self.view addSubview:loadingview];
- [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(loading) userInfo:nil repeats:NO];
- [super viewDidLoad];
- }
- - (void )loading {
- [loadingview removeFromSuperview];
- }
9、输入框点击done返回:
Objective-C代码
- 一、self.idinput.returnKeyType = UIReturnKeyDone;
- 二、然后设置按钮的代理;
三、
- -(BOOL )textFieldShouldReturn:(UITextField *)theTextField {
- [theTextField resignFirstResponder];
- return YES;
- }
10、alert的使用:
Objective-C代码
- UIAlertView *alertstart = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@ "Cancel" otherButtonTitles:@ "Easy" ,@ "Medium" ,@ "Hard" ,nil];
- [alertstart show];
- //弹出层选择
- - (void )alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
- if (buttonIndex == 0){ //取消
- stage = 0;
- }else {
- if (buttonIndex == 1){ //中等
- mainstageviewcontroller.gamelevel = 0;
- }else if (buttonIndex == 2){ //困难
- mainstageviewcontroller.gamelevel = 1;
- }else if (buttonIndex == 3){ //取消
- mainstageviewcontroller.gamelevel = 2;
- }
- [alertView release];
- }