質問編集履歴

2

ソースを修正

2016/01/21 08:26

投稿

uikura
uikura

スコア37

test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,39 @@
24
24
 
25
25
 
26
26
 
27
+ CGFloat inset = 20;
28
+
29
+ CGFloat settingsButtonHeight = 32;
30
+
31
+ CGFloat settingsButtonWidth = 32;
32
+
33
+
34
+
35
+ CGRect settingsButtonFrame = CGRectMake((screenFrame.size.width -52),
36
+
37
+ (screenFrame.size.height -52),
38
+
39
+ settingsButtonWidth,
40
+
41
+ settingsButtonHeight);
42
+
43
+
44
+
45
+ self.settingsButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
46
+
47
+ [self.settingsButton setFrame:settingsButtonFrame];
48
+
49
+ [self.settingsButton setTitle:@"押してね" forState:UIControlStateNormal];
50
+
51
+ [self.settingsButton setBackgroundColor:[UIColor redColor]];
52
+
53
+
54
+
27
- [self.settingsButton addTarget:self action:@selector(touchBtn:) forControlEvents:UIControlEventTouchUpInside];
55
+ [self.settingsButton addTarget:self action:@selector(touchBtn:) forControlEvents:UIControlEventTouchUpInside];
56
+
57
+ [self.view addSubview:self.settingsButton];
58
+
59
+
28
60
 
29
61
  }
30
62
 

1

処理を行っているメソッドについて

2016/01/21 08:26

投稿

uikura
uikura

スコア37

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,35 @@
6
6
 
7
7
  現在、TableView上にスクロールしないButton(スクロールされてもずっと定位置にいる)を配置しようと考えているのですが期待通りの位置にButtonが配置されません。ソースコードを以下に置きますのでどうか回答の方をよろしくお願いします。
8
8
 
9
+
10
+
11
+ 修正:
12
+
13
+ ButtonはviewDidLoadで生成しています。AutoLoyoutは効かせておりません。
14
+
15
+ Buttonを配置しようとしているところはscrollViewDidScrollでやっています
16
+
17
+
18
+
19
+ よろしくお願いします。
20
+
9
- ```
21
+ ```
22
+
23
+ - (void)viewDidLoad {
24
+
25
+
26
+
27
+ [self.settingsButton addTarget:self action:@selector(touchBtn:) forControlEvents:UIControlEventTouchUpInside];
28
+
29
+ }
30
+
31
+
32
+
33
+
34
+
35
+ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
36
+
37
+
10
38
 
11
39
  CGPoint point = CGPointMake(self.settingsButton.frame.size.width +scrollView.contentOffset.x,
12
40
 
@@ -16,7 +44,7 @@
16
44
 
17
45
  self.settingsButton.frame = CGRectMake(point.x,point.y,50,50);
18
46
 
19
-
47
+ }
20
48
 
21
49
  コード
22
50