・Link Binary With LibrariesにQuartzCore.frameworkを追加する。
・QuartzCore/QuartzCore.h をインポートする。
// 枠線の幅 view.layer.borderWidth = 1.0f; // 枠線の色 view.layer.borderColor = [[UIColor lightGrayColor] CGColor]; // 角丸をつける場合の半径 view.layer.cornerRadius = 8.0f;
// 枠線の幅 view.layer.borderWidth = 1.0f; // 枠線の色 view.layer.borderColor = [[UIColor lightGrayColor] CGColor]; // 角丸をつける場合の半径 view.layer.cornerRadius = 8.0f;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];
// つまみの画像 [_slider setThumbImage:[UIImage imageNamed:@"handle3.png"] forState:UIControlStateNormal]; [_slider setThumbImage:[UIImage imageNamed:@"handle3.png"] forState:UIControlStateHighlighted]; // 背景のバーの画像(最小値側) [_slider setMinimumTrackImage:[UIImage imageNamed:@"bg1.jpg"] forState:UIControlStateNormal]; // 背景のバーの画像(最大値側) [_slider setMaximumTrackImage:[UIImage imageNamed:@"bg2.jpg"] forState:UIControlStateNormal];
self.tableView.allowsSelection = NO;
if ([UIScreen mainScreen].scale == 2.0) { // retinaディスプレイ }
self.tableView.scrollsToTop = NO;
// iOS7のセパレータを端までのばす if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) { [self.tableView setSeparatorInset:UIEdgeInsetsZero]; }
@interface SliderViewController () @property (strong, nonatomic) UISlider *slider; @end @implementation SliderViewController - (void)viewDidLoad { [super viewDidLoad]; // スライダーの作成 _slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 100, 280, 50)]; // 最小値 _slider.minimumValue = 0.0f; // 最大値 _slider.maximumValue = 1.0f; // 現在値 _slider.value = 0.5f; // スライダー変更時のメソッド [_slider addTarget:self action:@selector(onChangeSlider:) forControlEvents:UIControlEventValueChanged]; // スライダーをviewに追加 [self.view addSubview:_slider]; } // スライダー変更時 - (void)onChangeSlider:(id)sender { UISlider *slider = (UISlider*)sender; NSLog(@"%f", slider.value); }
// 表示するセルのindexPath作成 NSIndexPath* indexPath = [NSIndexPath indexPathForRow:_index inSection:0]; // 指定セルまでスクロール // atScrollPosition: UITableViewScrollPositionNone 移動量少なくTableViewの表示に入るように // UITableViewScrollPositionTop TableViewの表示の先頭にスクロール // UITableViewScrollPositionMiddle TableViewの表示の真ん中にスクロール // UITableViewScrollPositionBottom TableViewの表示の末尾にスクロール [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
NSString *str = [NSString stringWithFormat:@"%.02f", width]; NSLog(str);
NSString *str = [NSString stringWithFormat:@"%.02f", width]; NSLog(@"%@", str);
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; // CompletionHandlerを設定 [composeVC setCompletionHandler:^(SLComposeViewControllerResult result) { [self dismissViewControllerAnimated:YES completion:nil]; if (result == SLComposeViewControllerResultDone) { NSLog(@"sendTwitter success"); } }]; // POSTするテキストの初期設定 NSString* message = [NSString stringWithFormat:@"XXXXXXXXXX"]; [composeVC setInitialText:message]; // URLをPOSTする場合 [composeVC addURL:[NSURL URLWithString:@"http://XXXXXXXX"]]; // 画像をPOSTする場合 [composeVC addImage:[UIImage imageNamed:@"XXXXX"]]; // SLComposeViewController表示 [self presentViewController:composeVC animated:YES completion:nil]; }CompletionHandlerに入れたdismissViewControllerAnimatedはiOS7.Xではなくても動いたが、
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; [composeVC setCompletionHandler:^(SLComposeViewControllerResult result) { [self dismissViewControllerAnimated:YES completion:nil]; if (result == SLComposeViewControllerResultDone) { DEBUG_LOG(@"sendFacebook success"); } }]; // POSTするテキストの初期設定 NSString* message = [NSString stringWithFormat:@"XXXXXXXXXX"]; [composeVC setInitialText:message]; // URLをPOSTする場合 [composeVC addURL:[NSURL URLWithString:@"http://XXXXXXXX"]]; // 画像をPOSTする場合 [composeVC addImage:[UIImage imageNamed:@"XXXXX"]]; // SLComposeViewController表示 [self presentViewController:composeVC animated:YES completion:nil]; }CompletionHandlerに入れたdismissViewControllerAnimatedはなくても動く。
// 名称 NSLog(@"name[%@]", [UIDevice currentDevice].name); // OS名 NSLog(@"systemName[%@]", [UIDevice currentDevice].systemName); // OSバージョン NSLog(@"systemVersion[%@]", [UIDevice currentDevice].systemVersion); // デバイスのモデル NSLog(@"model[%@]", [UIDevice currentDevice].model); NSLog(@"localizedModel[%@]", [UIDevice currentDevice].localizedModel); // デバイスのインターフェースタイプ(iPhoneかiPadか) // UIUserInterfaceIdiomPhone, UIUserInterfaceIdiomPad if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { NSLog(@"userInterfaceIdiom is iPad"); } else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) { NSLog(@"userInterfaceIdiom is iPhone"); } // アプリのベンダー毎のUUID NSLog(@"identifierForVendor[%@]", [UIDevice currentDevice].identifierForVendor);
2014-04-13 13:42:21.503 Device[5307:60b] name[XXXのiPad] 2014-04-13 13:42:21.505 Device[5307:60b] systemName[iPhone OS] 2014-04-13 13:42:21.506 Device[5307:60b] systemVersion[7.0.6] 2014-04-13 13:42:21.507 Device[5307:60b] model[iPad] 2014-04-13 13:42:21.509 Device[5307:60b] localizedModel[iPad] 2014-04-13 13:42:21.510 Device[5307:60b] userInterfaceIdiom is iPad 2014-04-13 13:42:21.515 Device[5307:60b] identifierForVendor[<__nsconcreteuuid 0x15604e20> D291C209-B5AF-430A-9AC5-66859F0AF1CB]
// 回転するかどうか - (BOOL)shouldAutorotate { // 回転したときのViewの配置等の処理を記述 // 回転する場合YES, しない場合NO return YES; }
// サポートするインターフェースの向き - (NSUInteger)supportedInterfaceOrientations { // UIInterfaceOrientationMaskPortrait : 縦(ホームボタン下) // UIInterfaceOrientationMaskLandscapeLeft : 横(ホームボタン左) // UIInterfaceOrientationMaskLandscapeRight : 横(ホームボタン右) // UIInterfaceOrientationMaskPortraitUpsideDown : 縦(ホームボタン上) // UIInterfaceOrientationMaskLandscape : 横(両方) // UIInterfaceOrientationMaskAll : 4つ全て // UIInterfaceOrientationMaskAllButUpsideDown : 縦(ホームボタン上)以外の3つ return UIInterfaceOrientationMaskLandscape; }
// インターフェースの向き(初期状態) - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { NSLog(@"preferredInterfaceOrientationForPresentation"); // UIInterfaceOrientationPortrait : 縦(ホームボタン下) // UIInterfaceOrientationPortraitUpsideDown : 縦(ホームボタン上) // UIInterfaceOrientationLandscapeLeft : 横(ホームボタン左) // UIInterfaceOrientationLandscapeRight : 横(ホームボタン右) return UIInterfaceOrientationLandscapeRight; }