iosの開発過程におけるいくつかのノートは、絶えず更新中です.の


学習中の点滴を記録する:
1、nsobjectから継承してもuiviewcontrollerから継承しても、いくつかのものを初期化するときは、プログラムの実行後に1回だけ歩く必要があります.例えば、いくつかのページの初期値、いくつかのmodelの初期値などです.プログラムを実行するだけで初期化する必要がある場合は、この2つの方法を呼び出すことができます.
+(void)initialize{
}
+(void)load{
}
この2つの方法は、プログラムの実行後に実行され、1回しか実行されません.
2、buttonのタイトルとbuttonの境界の距離を設定します.例えば、タイトルが中央にあるのではなく、タイトルが右の境界から30ピクセル離れている場合は、buttonの内容の位置合わせを先に設定する必要があります.
startButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
次に、UIedgeInsetsを定義します.
UIEdgeInsets edgeInset =UIEdgeInsetsMake(0,0,0,30);
最後にbuttonのtitleEdgeInsetsを自分で定義したUIedgeInsetsに設定します
startButton.titleEdgeInsets = edgeInset
成功!
3、UIdatePickerの表示中英文問題を設定する
NSLocale *locale = [[NSLocalealloc]initWithLocaleIdentifier:@"en_US"];//英語表示に設定
NSLocale *locale = [[NSLocalealloc]initWithLocaleIdentifier:@"zh_CN"];//中国語表示に設定
datePicker.locale = locale;
ok!!!
4、UIdatePickerの表示を設定する
//0-大背景の色;1-ボックスの左の色を選択します.2-? ;3-?; 5-スクロール領域のカラーオーバーライドデータ
//6-選択ボックスの背景色7-選択ボックスの左側の色8-View全体の色はすべてのピクチャUIView*view=[[self subviews]objectAtIndex:6]を上書きします.    [view setBackgroundColor:[UIColor clearColor]];     UIImageView *bgimg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"picker_tiao.png"]];     bgimg.frame = CGRectMake(-5, -3, 200, 55);     [view addSubview:bgimg];     [self setNeedsDisplay];
ok!!!
5、キーボードの高さを取得する
まず、キーボードがポップアップされたときに通知する通知を登録します.
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil];そして、キーボードがイジェクトされると、OIKEeyboardFrameBeginUserInfoKeyの対応する値をobjectForKey:UIIIKEeyboardFrameBeginUserInfoKeyの対応する値でキーボードの高さを取得する-(void)keyboardWasShown:(NSNotification*)notif{NSDictionary*info=[notiuserInfo];NSValue*value=[info objectForKey:UIKEeyboardFrameBeginUserInfoKey];CGSizekeyboardSize=[value CGRectValue].size;NSLog(@""@keyBoard:%f",keyboardSize.height); //216      keyboardWasShown = YES;  } 
OK!!!
6、一つの画像を回転させる
 CABasicAnimation* rotationAnimation;
                rotationAnimation = [CABasicAnimationanimationWithKeyPath:@"transform.rotation.z"];
                rotationAnimation.toValue = [NSNumbernumberWithFloat:M_PI *2.0 ];
                [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
                rotationAnimation.duration =10;
                rotationAnimation.repeatCount =9999;//最大の整数値に設定できます
                rotationAnimation.cumulative =NO;
                rotationAnimation.removedOnCompletion =NO;
                rotationAnimation.fillMode =kCAFillModeForwards;
                    [self.weatherImageView.layeraddAnimation:rotationAnimationforKey:@"Rotation"];
7、pagecontrolのドットの色を変更する
UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame: ... pageControl.numberOfPages = 5; 
pageControl.currentPageIndicatorTintColor = [UIColor redColor];
pageControl.pageIndicatorTintColor = [UIColor greenColor];
やった!!
8、現在のデバイスがiphoneかどうかを判断する
[[UIDevicecurrentDevice] userInterfaceIdiom] ==UIUserInterfaceIdiomPhone
[[UIdevice currentDevice]userInterfaceIdiom]=UIUserInterfaceIdiomPad現在のデバイスがipadであるかどうかを判断
9、一つの画像を一つの点の周りに回転させる
-(void)startAnimation{[UIView beginAnimations:nil context:nil];[UIView setAnimationDuration:0.05];[UIView setAnimationDelegte:self];[U IView setAnimationDidStopSelector:@selector(startAnimation)];self.angle+=5;self.saomiao.layer.anchorPoint=CGPointMake(1,1);//右下角を原点として回り(0,0,0,0,0,0,0,0,0,0,0,0,0,1);//右下角を原点として回転する0)は左上隅回転、(0.5,0,5)心の中で回転して、その他はこのようにselfを押します.saomiao.transform = CGAffineTransformMakeRotation(self.angle * (M_PI/180.0f));
[UIView commitAnimations];

}
どんどん更新中...