How to make header view clickable of tableview in Swift
is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.

I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.
ios swift tableview
|
show 2 more comments
is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.

I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.
ios swift tableview
1
yes put a view on it use UITapGesture
– wings
Nov 14 '18 at 12:15
You can use collcetionview with flowlayout
– SPatel
Nov 14 '18 at 12:17
@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell
– harinder rana
Nov 14 '18 at 12:19
one team group = one section
– SPatel
Nov 14 '18 at 12:23
use supplementary view for header
– SPatel
Nov 14 '18 at 12:24
|
show 2 more comments
is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.

I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.
ios swift tableview
is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.

I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.
ios swift tableview
ios swift tableview
edited Nov 14 '18 at 14:51
Cœur
18.2k9108148
18.2k9108148
asked Nov 14 '18 at 12:13
harinder ranaharinder rana
177
177
1
yes put a view on it use UITapGesture
– wings
Nov 14 '18 at 12:15
You can use collcetionview with flowlayout
– SPatel
Nov 14 '18 at 12:17
@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell
– harinder rana
Nov 14 '18 at 12:19
one team group = one section
– SPatel
Nov 14 '18 at 12:23
use supplementary view for header
– SPatel
Nov 14 '18 at 12:24
|
show 2 more comments
1
yes put a view on it use UITapGesture
– wings
Nov 14 '18 at 12:15
You can use collcetionview with flowlayout
– SPatel
Nov 14 '18 at 12:17
@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell
– harinder rana
Nov 14 '18 at 12:19
one team group = one section
– SPatel
Nov 14 '18 at 12:23
use supplementary view for header
– SPatel
Nov 14 '18 at 12:24
1
1
yes put a view on it use UITapGesture
– wings
Nov 14 '18 at 12:15
yes put a view on it use UITapGesture
– wings
Nov 14 '18 at 12:15
You can use collcetionview with flowlayout
– SPatel
Nov 14 '18 at 12:17
You can use collcetionview with flowlayout
– SPatel
Nov 14 '18 at 12:17
@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell
– harinder rana
Nov 14 '18 at 12:19
@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell
– harinder rana
Nov 14 '18 at 12:19
one team group = one section
– SPatel
Nov 14 '18 at 12:23
one team group = one section
– SPatel
Nov 14 '18 at 12:23
use supplementary view for header
– SPatel
Nov 14 '18 at 12:24
use supplementary view for header
– SPatel
Nov 14 '18 at 12:24
|
show 2 more comments
2 Answers
2
active
oldest
votes
You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
add a comment |
header view of tableview are buttons, or you could use tap gesture.
header view has a block property, you could write your business in .
optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
And you can use delegate pattern.
There ie no api like
optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)
for tableView
like this
var callback: (() -> Void)!
var label = UILabel()
override init(frame: CGRect)
super.init(frame: frame)
label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
label.addGestureRecognizer(tap)
@objc func do_it()
callback()
how we can target the headerview in tap gesture? @dengApro
– harinder rana
Nov 14 '18 at 12:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299998%2fhow-to-make-header-view-clickable-of-tableview-in-swift%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
add a comment |
You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
add a comment |
You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
answered Nov 14 '18 at 12:50
Kiran PadhiyarKiran Padhiyar
113
113
add a comment |
add a comment |
header view of tableview are buttons, or you could use tap gesture.
header view has a block property, you could write your business in .
optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
And you can use delegate pattern.
There ie no api like
optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)
for tableView
like this
var callback: (() -> Void)!
var label = UILabel()
override init(frame: CGRect)
super.init(frame: frame)
label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
label.addGestureRecognizer(tap)
@objc func do_it()
callback()
how we can target the headerview in tap gesture? @dengApro
– harinder rana
Nov 14 '18 at 12:28
add a comment |
header view of tableview are buttons, or you could use tap gesture.
header view has a block property, you could write your business in .
optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
And you can use delegate pattern.
There ie no api like
optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)
for tableView
like this
var callback: (() -> Void)!
var label = UILabel()
override init(frame: CGRect)
super.init(frame: frame)
label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
label.addGestureRecognizer(tap)
@objc func do_it()
callback()
how we can target the headerview in tap gesture? @dengApro
– harinder rana
Nov 14 '18 at 12:28
add a comment |
header view of tableview are buttons, or you could use tap gesture.
header view has a block property, you could write your business in .
optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
And you can use delegate pattern.
There ie no api like
optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)
for tableView
like this
var callback: (() -> Void)!
var label = UILabel()
override init(frame: CGRect)
super.init(frame: frame)
label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
label.addGestureRecognizer(tap)
@objc func do_it()
callback()
header view of tableview are buttons, or you could use tap gesture.
header view has a block property, you could write your business in .
optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
And you can use delegate pattern.
There ie no api like
optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)
for tableView
like this
var callback: (() -> Void)!
var label = UILabel()
override init(frame: CGRect)
super.init(frame: frame)
label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
label.addGestureRecognizer(tap)
@objc func do_it()
callback()
edited Nov 14 '18 at 12:37
answered Nov 14 '18 at 12:22
dengAprodengApro
1,06411122
1,06411122
how we can target the headerview in tap gesture? @dengApro
– harinder rana
Nov 14 '18 at 12:28
add a comment |
how we can target the headerview in tap gesture? @dengApro
– harinder rana
Nov 14 '18 at 12:28
how we can target the headerview in tap gesture? @dengApro
– harinder rana
Nov 14 '18 at 12:28
how we can target the headerview in tap gesture? @dengApro
– harinder rana
Nov 14 '18 at 12:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299998%2fhow-to-make-header-view-clickable-of-tableview-in-swift%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
yes put a view on it use UITapGesture
– wings
Nov 14 '18 at 12:15
You can use collcetionview with flowlayout
– SPatel
Nov 14 '18 at 12:17
@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell
– harinder rana
Nov 14 '18 at 12:19
one team group = one section
– SPatel
Nov 14 '18 at 12:23
use supplementary view for header
– SPatel
Nov 14 '18 at 12:24