0

在此处输入图像描述

我想在images我的上方制作 2 tableView- 一个image在顶部,一个在视图底部。就像图片上的一样。我image在顶部成功了(当我滚动 时tableView,它在图像下方滚动),但是,image底部的 没有出现。我所做的是,我只是调整了 的大小tableView并在顶部和底部缩短了它并添加了UIImageView's. 但在底部,没有image. 我也尝试在代码中做到这一点:

CGRect flagsFrame = CGRectMake(0, 460, 320, 11);

UIImageView *bottomFlags = [[UIImageView alloc]initWithFrame:flagsFrame];
bottomFlags.image = [UIImage imageNamed:@"flags_down"];

[self.view addSubview:bottomFlags];
[self.view bringSubviewToFront:bottomFlags];

但什么也没有发生。为什么没有图片?看起来像tableView覆盖图像或其他东西。

谢谢 !

升级版:

<UIWindow: 0x1be340; frame = (0 0; 320 480); layer = <UIWindowLayer: 0x1be430>>
   | <UILayoutContainerView: 0x1c0d00; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x1c0da0>>
   |    | <UITransitionView: 0x1c1040; frame = (0 0; 320 431); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1c1410>>
   |    |    | <UIViewControllerWrapperView: 0x1ca7a0; frame = (0 0; 320 431); autoresize = W+H; layer = <CALayer: 0x1ca0b0>>
   |    |    |    | <UILayoutContainerView: 0x1c5bf0; frame = (0 0; 320 431); autoresize = W+H; layer = <CALayer: 0x1c5c40>>
   |    |    |    |    | <UINavigationTransitionView: 0x1c5fa0; frame = (0 0; 320 431); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1c4da0>>
   |    |    |    |    |    | <UIViewControllerWrapperView: 0x108ff0; frame = (0 64; 320 367); autoresize = W+H; layer = <CALayer: 0x109020>>
   |    |    |    |    |    |    | <UIView: 0x1d43f0; frame = (0 0; 320 367); autoresize = W+H; layer = <CALayer: 0x13bce0>>
   |    |    |    |    |    |    |    | <UIImageView: 0x13bd10; frame = (0 0; 320 460); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x140fa0>>
   |    |    |    |    |    |    |    | <UITableView: 0x9ec800; frame = (0 0; 320 367); clipsToBounds = YES; opaque = NO; autoresize = W+H; layer = <CALayer: 0x19cda0>; contentOffset: {0, 4165.5}>
   |    |    |    |    |    |    |    |    | <CustomCell: 0x10f5b0; baseClass = UITableViewCell; frame = (0 4097; 320 75); autoresize = W; layer = <CALayer: 0x10b1e0>>
   |    |    |    |    |    |    |    |    |    | <UIGroupTableViewCellBackground: 0x10f510; frame = (9 0; 302 75); autoresize = W; layer = <CALayer: 0x13c330>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x19eae0; frame = (1 0; 300 1); hidden = YES; autoresize = W; layer = <CALayer: 0x125990>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x10e9b0; frame = (1 74; 300 1); hidden = YES; autoresize = W+TM; layer = <CALayer: 0x128fe0>>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10f6c0; frame = (10 0; 280 74); layer = <CALayer: 0x109620>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x115880; frame = (70 10; 350 25); userInteractionEnabled = NO; layer = <CALayer: 0x18d1e0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x13ba00; frame = (70 10; 230 25); text = 'Слиток'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x117da0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x13eef0; frame = (70 40; 120 18); text = 'Бесценно'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x126be0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10e350; frame = (10 10; 50 50); userInteractionEnabled = NO; layer = <CALayer: 0x117c30>>
   |    |    |    |    |    |    |    |    |    | <UIButton: 0x109ab0; frame = (280 0; 30 74); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10d080>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x191090; frame = (10 30; 10 13); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x11b880>>
   |    |    |    |    |    |    |    |    |    | <UIView: 0x10e2e0; frame = (10 0; 300 1); layer = <CALayer: 0x10e310>>
   |    |    |    |    |    |    |    |    | <CustomCell: 0x1ca8b0; baseClass = UITableViewCell; frame = (0 4172; 320 75); autoresize = W; layer = <CALayer: 0x11cee0>>
   |    |    |    |    |    |    |    |    |    | <UIGroupTableViewCellBackground: 0x11e610; frame = (9 0; 302 75); autoresize = W; layer = <CALayer: 0x1c5da0>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x1dd650; frame = (1 0; 300 1); hidden = YES; autoresize = W; layer = <CALayer: 0x11d140>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x117d50; frame = (1 74; 300 1); hidden = YES; autoresize = W+TM; layer = <CALayer: 0x143680>>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x1183f0; frame = (10 0; 280 74); layer = <CALayer: 0x16e8a0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x130740; frame = (70 10; 350 25); userInteractionEnabled = NO; layer = <CALayer: 0x10c170>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x116b70; frame = (70 10; 230 25); text = 'Бонго'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x10cc60>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x115d80; frame = (70 40; 120 18); text = '$15 - $120'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x115bb0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x12e9c0; frame = (10 10; 50 50); userInteractionEnabled = NO; layer = <CALayer: 0x143620>>
   |    |    |    |    |    |    |    |    |    | <UIButton: 0x11e580; frame = (280 0; 30 74); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x15a240>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x11f520; frame = (10 30; 10 13); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1dd1d0>>
   |    |    |    |    |    |    |    |    |    | <UIView: 0x11e350; frame = (10 0; 300 1); layer = <CALayer: 0x118540>>
   |    |    |    |    |    |    |    |    | <CustomCell: 0x11c420; baseClass = UITableViewCell; frame = (0 4247; 320 75); autoresize = W; layer = <CALayer: 0x1912b0>>
   |    |    |    |    |    |    |    |    |    | <UIGroupTableViewCellBackground: 0x112f10; frame = (9 0; 302 75); autoresize = W; layer = <CALayer: 0x11e230>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x117aa0; frame = (1 0; 300 1); hidden = YES; autoresize = W; layer = <CALayer: 0x109940>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x1decf0; frame = (1 74; 300 1); hidden = YES; autoresize = W+TM; layer = <CALayer: 0x123b60>>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x115c60; frame = (10 0; 280 74); layer = <CALayer: 0x7275af0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10b7c0; frame = (70 10; 350 25); userInteractionEnabled = NO; layer = <CALayer: 0x101330>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x128e70; frame = (70 10; 230 25); text = 'Кресло массажер'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x117520>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x10e3b0; frame = (70 40; 120 18); text = '$10 - $75'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x104c50>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x18dc70; frame = (10 10; 50 50); userInteractionEnabled = NO; layer = <CALayer: 0x10f270>>
   |    |    |    |    |    |    |    |    |    | <UIButton: 0x112e80; frame = (280 0; 30 74); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x11ceb0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x111890; frame = (10 30; 10 13); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x11e6b0>>
   |    |    |    |    |    |    |    |    |    | <UIView: 0x114480; frame = (10 0; 300 1); layer = <CALayer: 0x11d110>>
   |    |    |    |    |    |    |    |    | <CustomCell: 0x115fc0; baseClass = UITableViewCell; frame = (0 4322; 320 75); autoresize = W; layer = <CALayer: 0x125960>>
   |    |    |    |    |    |    |    |    |    | <UIGroupTableViewCellBackground: 0x10ceb0; frame = (9 0; 302 75); autoresize = W; layer = <CALayer: 0x116220>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x11e280; frame = (1 0; 300 1); hidden = YES; autoresize = W; layer = <CALayer: 0x11e2b0>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x10edb0; frame = (1 74; 300 1); hidden = YES; autoresize = W+TM; layer = <CALayer: 0x10ede0>>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x11c540; frame = (10 0; 280 74); layer = <CALayer: 0x1179a0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x112940; frame = (70 10; 350 25); userInteractionEnabled = NO; layer = <CALayer: 0x10e530>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x111090; frame = (70 10; 230 25); text = 'Громкоговоритель'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x110a30>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x1423c0; frame = (70 40; 120 18); text = '$10 - $75'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x11c5a0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x130880; frame = (10 10; 50 50); userInteractionEnabled = NO; layer = <CALayer: 0x11b8b0>>
   |    |    |    |    |    |    |    |    |    | <UIButton: 0x10d650; frame = (280 0; 30 74); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1910f0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10a9a0; frame = (10 30; 10 13); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10e4d0>>
   |    |    |    |    |    |    |    |    |    | <UIView: 0x117a00; frame = (10 0; 300 1); layer = <CALayer: 0x117a30>>
   |    |    |    |    |    |    |    |    | <CustomCell: 0x12d010; baseClass = UITableViewCell; frame = (0 4397; 320 75); autoresize = W; layer = <CALayer: 0x123b30>>
   |    |    |    |    |    |    |    |    |    | <UIGroupTableViewCellBackground: 0x111640; frame = (9 0; 302 75); autoresize = W; layer = <CALayer: 0x1f2260>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x1116a0; frame = (1 0; 300 1); hidden = YES; autoresize = W; layer = <CALayer: 0x10ebf0>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x10ec20; frame = (1 74; 300 1); hidden = YES; autoresize = W+TM; layer = <CALayer: 0x10ec50>>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x10c100; frame = (10 0; 280 74); layer = <CALayer: 0x10f330>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x11b8e0; frame = (70 10; 350 25); userInteractionEnabled = NO; layer = <CALayer: 0x1185b0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x115f50; frame = (70 10; 230 25); text = 'Перочиный ножик'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x109820>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x115d10; frame = (70 40; 120 18); text = '$15 - $80'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x1f22e0>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x112900; frame = (10 10; 50 50); userInteractionEnabled = NO; layer = <CALayer: 0x10ce80>>
   |    |    |    |    |    |    |    |    |    | <UIButton: 0x10f470; frame = (280 0; 30 74); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1ca720>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10dee0; frame = (10 30; 10 13); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10df20>>
   |    |    |    |    |    |    |    |    |    | <UIView: 0x1125d0; frame = (10 0; 300 1); layer = <CALayer: 0x118100>>
   |    |    |    |    |    |    |    |    | <CustomCell: 0x11c310; baseClass = UITableViewCell; frame = (0 4472; 320 75); autoresize = W; layer = <CALayer: 0x11ce00>>
   |    |    |    |    |    |    |    |    |    | <UIGroupTableViewCellBackground: 0x10b580; frame = (9 0; 302 75); autoresize = W; layer = <CALayer: 0x155850>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x155880; frame = (1 0; 300 1); hidden = YES; autoresize = W; layer = <CALayer: 0x1128d0>>
   |    |    |    |    |    |    |    |    |    |    | <UIView: 0x10bb80; frame = (1 74; 300 1); hidden = YES; autoresize = W+TM; layer = <CALayer: 0x10bbb0>>
   |    |    |    |    |    |    |    |    |    | <UITableViewCellContentView: 0x11cc70; frame = (10 0; 280 74); layer = <CALayer: 0x109b90>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x1dd5f0; frame = (70 10; 350 25); userInteractionEnabled = NO; layer = <CALayer: 0x1185e0>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x115ca0; frame = (70 10; 230 25); text = 'Игровая консоль'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x117c00>>
   |    |    |    |    |    |    |    |    |    |    | <UILabel: 0x162e10; frame = (70 40; 120 18); text = '$170 - $500'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x10c140>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x10cc10; frame = (10 10; 50 50); userInteractionEnabled = NO; layer = <CALayer: 0x173d10>>
   |    |    |    |    |    |    |    |    |    | <UIButton: 0x10bc90; frame = (280 0; 30 74); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x140a90>>
   |    |    |    |    |    |    |    |    |    |    | <UIImageView: 0x109360; frame = (10 30; 10 13); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x10f740>>
   |    |    |    |    |    |    |    |    |    | <UIView: 0x118350; frame = (10 0; 300 1); layer = <CALayer: 0x118380>>
   |    |    |    |    |    |    |    |    | <UIImageView: 0x142450; frame = (0 360; 320 7); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x15dc80>>
   |    |    |    |    |    |    |    |    | <UIImageView: 0x100b70; frame = (0 5608; 320 11); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x141f60>>
   |    |    |    |    |    |    |    |    | <UIImageView: 0x1d4d20; frame = (312 4427.5; 7 36); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x1d4d80>>
   |    |    |    |    |    |    |    | <UIImageView: 0x12ea90; frame = (0 0; 320 11); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x126aa0>>
   |    |    |    |    |    |    |    | <UILabel: 0x124eb0; frame = (0 -135; 320 90); text = 'В комплекте подарите деву...'; clipsToBounds = YES; hidden = YES; userInteractionEnabled = NO; layer = <CALayer: 0x13ff90>>
   |    |    |    |    |    |    |    | <UIImageView: 0x72763e0; frame = (126 -64; 64 64); hidden = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x7275840>>
   |    |    |    |    | <UINavigationBar: 0x1c5c70; frame = (0 20; 320 44); autoresize = W; layer = <CALayer: 0x1c5d60>>
   |    |    |    |    |    | <UINavigationBarBackground: 0x1c5f60; frame = (0 0; 320 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1c5ff0>>
   |    |    |    |    |    | <UINavigationItemView: 0x1c17c0; frame = (116 8; 88 27); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1c1810>>
   |    |    |    |    |    | <UINavigationItemButtonView: 0x1c1840; frame = (5 7; 80 30); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x109560>>
   |    | <UITabBar: 0x1c0fe0; frame = (0 431; 320 49); autoresize = W+TM; layer = <CALayer: 0x1c10c0>>
   |    |    | <_UITabBarBackgroundView: 0x1c1290; frame = (0 0; 320 49); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1c1320>>
   |    |    | <UITabBarButton: 0x1c89e0; frame = (2 1; 103 48); opaque = NO; layer = <CALayer: 0x1c9be0>>
   |    |    |    | <UITabBarSelectionIndicatorView: 0x1ca310; frame = (0 2; 103 44); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1ca3a0>>
   |    |    |    | <UITabBarSwappableImageView: 0x1c9770; frame = (28 2; 48 32); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1c82c0>>
   |    |    |    | <UITabBarButtonLabel: 0x1c9a40; frame = (27 34; 50 13); text = 'Giftopedia'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1c9b50>>
   |    |    | <UITabBarButton: 0x1ca9c0; frame = (109 1; 102 48); opaque = NO; layer = <CALayer: 0x1c0c00>>
   |    |    |    | <UITabBarSwappableImageView: 0x1c96a0; frame = (27 2; 48 32); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1c9bb0>>
   |    |    |    | <UITabBarButtonLabel: 0x1c8100; frame = (24 34; 55 13); text = 'Избранное'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1c9700>>
   |    |    | <UITabBarButton: 0x1ca4a0; frame = (215 1; 103 48); opaque = NO; layer = <CALayer: 0x1caff0>>
   |    |    |    | <UITabBarSwappableImageView: 0x1c8830; frame = (27 2; 48 32); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1cb0c0>>
   |    |    |    | <UITabBarButtonLabel: 0x1c8380; frame = (18 34; 66 13); text = 'Информация'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1bf790>>
4

3 回答 3

1

看过去recursiveDescription,我看到两个UIImageView大小为 320x11 的 s。一个是 的兄弟UITableView

<UIImageView: 0x12ea90; frame = (0 0; 320 11); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x126aa0>>

此图像视图的原点位于 (0,0),因此我推断它是顶部图像视图。它UITableView在输出中列在 之后,这意味着它在堆叠顺序中位于 table view 的上方 - 它“更接近”用户的眼睛,并将绘制在 table view 的顶部。

另一个尺寸为 320x11 的图像视图被列为表视图的子视图:

<UIImageView: 0x100b70; frame = (0 5608; 320 11); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x141f60>>

所以在我看来,您将底部图像视图添加为表格视图的子视图,但您需要将其添加为表格视图的兄弟。您需要将其添加为表视图的超级视图的子视图。

于 2012-07-17T04:00:21.877 回答
1

如果您希望图像保持在表格顶部

如果您希望 UItableView 上的图像始终如一,则将 UITableView 和两个页眉/页脚视图作为同一 UIView 的子视图并将页眉/页脚视图放在前面。诀窍是关闭他们userInteraction的触摸通过他们到UITableView下面。

UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,460)];
[container addSubview:tableView];
[container addSubview:headerView];
[container addSubview:footerView];

headerView.userInteractionEnabled = NO;
footerView.userInteractionEnabled = NO;

如果您希望图像随表格滚动

您应该在 UITableView 实例的顶部和底部使用tableHeaderView和设置 UIView。tableFooterView

于 2012-07-17T04:01:05.720 回答
0

it seem there is a little problem in this line:

bottomFlags.image = [UIImage imageNamed:@"flags_down"];

try to add an extension for the image's name (.png), otherwise the the image property will be nil and you won't see the image in your entire life.

于 2012-07-17T08:45:36.897 回答