UITableViewサイドセクションヘッダー画像
-
25-09-2019 - |
質問
音楽アプリのiPadには多くの興味深いカスタムUIの特徴の一つであるテーブルビューの表示時のみ アルバムの特定の作家.
で画像の側面の各部門からのほとんど動いて,非常に類似したファッションへのセクションヘッダー。ればスクロールのトップ画像があるまで次の画像がやって来てるバンプで、その逆も当てはまります。
当初はそうでもな再実装のUITableViewすべてのもう一度ひっくり返してもう一つだと思いま半可るだけでは、サブクラスは、UITableViewを描くこれらの画像を、外部のuitableviewのを、いつで layoutSubviews
(まで幅).ある若干の問題本で描外のUITableView、autoresizingろによると、全体レイアウト。とんかつかめなかの実現可能性があります。
意思い?
編集:ただ私の最初の想いがその他の接触の画像側うな追跡のtableviewでせんでしたが、少し足を延ばせばスクロールの場合に触れます。私の最大の課題はどのように実施するかを伝搬するに触れるタッチを追跡全体ます。
解決 2
考えてみるとランダムには、深夜、最後に行っ不溶液とする。
組み込みのUITableviewにUIScrollViewのユーザーの巻物は、メチを通じて親scrollviewのtableviewです。など様々な機能が詰まっていればよいのlayoutSubviews法以来、layoutSubviewsのscrollviewするときに呼び出され、ユーザロ、ビューを変えるだけのフレームのtableview泊固定画面変更のtableviewのcontentOffset合わせることにscrollview.
例コード:
- (void) layoutSubviews{
tableView.frame = CGRectMake(self.contentOffset.x, self.contentOffset.y, tableView.frame.size.width, tableView.frame.size.height);
tableView.contentOffset = self.contentOffset;
}
この点を調整することができtableviewをやりたいことしたいのです。
他のヒント
きを確認するのtableviewを最など)、なんとかしたいUIViewを取得するたびに更新の変更、私の考えは少しているものではないやり直UITableViewで、別のビューの横に表示なし画像の代わりにしようと埋め込みが可能です。
ここはドービルカルバドストリッキーができるようにインデント細胞になっ開始の左側のテーブルビューのtableview非常に広いカスタムビューのヘッダが含まれる画像の左に思いを確認してください。◆良い質問で、楽しい一ます。
大丈夫でしょうがないようなものは何の音楽アプリやスポットライト検索す。
いないサブクラス化UITableViewいだけで追跡を通しscrollViewDidScroll方法を追加したヘッダのビューを左のtableView(そのためのtableviewを右におviewControllerので、使用できませんUITableViewController).
このメソッドを呼び出す必要があるscrollViewDidScroll,ViewDidLoad、didRotateFromInterfaceOrientation:(ご支援に回転)
うまいのと同じサイズのヘッダanyインタフェースの向きます。
-(void)updateHeadersLocation
{
for (int sectionNumber = 0; sectionNumber != [self numberOfSectionsInTableView:self.tableView]; sectionNumber++)
{
// get the rect of the section from the tableview, and convert it to it's superview's coordinates
CGRect rect = [self.tableView convertRect:[self.tableView rectForSection:sectionNumber] toView:[self.tableView superview]];
// get the intersection between the section's rect and the view's rect, this will help in knowing what portion of the section is showing
CGRect intersection = CGRectIntersection(rect, self.tableView.frame);
CGRect viewFrame = CGRectZero; // we will start off with zero
viewFrame.size = [self headerSize]; // let's set the size
viewFrame.origin.x = [self headerXOrigin];
/*
three cases:
1. the section's origin is still showing -> header view will follow the origin
2. the section's origin isn't showing but some part of the section still shows -> header view will stick to the top
3. the part of the section that's showing is not sufficient for the view's height -> will move the header view up
*/
if (rect.origin.y >= self.tableView.frame.origin.y)
{
// case 1
viewFrame.origin.y = rect.origin.y;
}
else
{
if (intersection.size.height >= viewFrame.size.height)
{
// case 2
viewFrame.origin.y = self.tableView.frame.origin.y;
}
else
{
// case 3
viewFrame.origin.y = self.tableView.frame.origin.y + intersection.size.height - viewFrame.size.height;
}
}
UIView* view = [self.headerViewsDictionary objectForKey:[NSString stringWithFormat:@"%i", sectionNumber]];
// check if the header view is needed
if (intersection.size.height == 0)
{
// not needed, remove it
if (view)
{
[view removeFromSuperview];
[self.headerViewsDictionary removeObjectForKey:[NSString stringWithFormat:@"%i", sectionNumber]];
view = nil;
}
}
else if(!view)
{
// needed, but not available, create it and add it as a subview
view = [self headerViewForSection:sectionNumber];
if (!self.headerViewsDictionary && view)
self.headerViewsDictionary = [NSMutableDictionary dictionary];
if (view)
{
[self.headerViewsDictionary setValue:view forKey:[NSString stringWithFormat:@"%i", sectionNumber]];
[self.view addSubview:view];
}
}
[view setFrame:viewFrame];
}
}
また、申告する必要はあり、物件の景色が見える:
@property (nonatomic, strong) NSMutableDictionary* headerViewsDictionary;
これらのメソッドはサイズのX軸をオフセットのヘッダのビューもあります:
-(CGSize)headerSize
{
return CGSizeMake(44.0f, 44.0f);
}
-(CGFloat)headerXOrigin
{
return 10.0f;
}
いのコードにその他のヘッダビューとなく削除されていた方法に還の必要に応じ:
-(UIView*)headerViewForSection:(NSInteger)index
{
UIImageView* view = [[UIImageView alloc] init];
if (index % 2)
{
[view setImage:[UIImage imageNamed:@"call"]];
}
else
{
[view setImage:[UIImage imageNamed:@"mail"]];
}
return view;
}
こちらはどのように見えてしまう:
どのように見えてしまうでlanscape使用しているcontraintsを44px左のtableView
武器agiは、dexで下がらないboxerぐ:).