[Swift4]UIRefreshControl Indicator appear at different position
I am trying to make an iOS app, using Xcode 10.1 (10B61) and Swift4.
I have an issue about UIRefreshControl Indicator appearance, like the image below.
UIRefreshControl script is written in each TableViewController class (same code about refresh func).
class TableViewController1: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
Anybody please give me some advise.
Thank you.
ios swift
add a comment |
I am trying to make an iOS app, using Xcode 10.1 (10B61) and Swift4.
I have an issue about UIRefreshControl Indicator appearance, like the image below.
UIRefreshControl script is written in each TableViewController class (same code about refresh func).
class TableViewController1: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
Anybody please give me some advise.
Thank you.
ios swift
1
I guess you are missing to set the frame or offset forUIRefreshControl
– Mukesh
Nov 22 '18 at 6:18
add a comment |
I am trying to make an iOS app, using Xcode 10.1 (10B61) and Swift4.
I have an issue about UIRefreshControl Indicator appearance, like the image below.
UIRefreshControl script is written in each TableViewController class (same code about refresh func).
class TableViewController1: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
Anybody please give me some advise.
Thank you.
ios swift
I am trying to make an iOS app, using Xcode 10.1 (10B61) and Swift4.
I have an issue about UIRefreshControl Indicator appearance, like the image below.
UIRefreshControl script is written in each TableViewController class (same code about refresh func).
class TableViewController1: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
}
Anybody please give me some advise.
Thank you.
ios swift
ios swift
edited Nov 22 '18 at 9:17
wvteijlingen
8,77912545
8,77912545
asked Nov 22 '18 at 5:54
himiyo3inhimiyo3in
132
132
1
I guess you are missing to set the frame or offset forUIRefreshControl
– Mukesh
Nov 22 '18 at 6:18
add a comment |
1
I guess you are missing to set the frame or offset forUIRefreshControl
– Mukesh
Nov 22 '18 at 6:18
1
1
I guess you are missing to set the frame or offset for
UIRefreshControl
– Mukesh
Nov 22 '18 at 6:18
I guess you are missing to set the frame or offset for
UIRefreshControl
– Mukesh
Nov 22 '18 at 6:18
add a comment |
3 Answers
3
active
oldest
votes
This happens because of combination of things.
You're using large headers for navigation controller. That makes
TableViewController
(actually any scrollable view) to put itsrefreshControl
on navigation bar . This behaviour was introduced in iOS 11 https://developer.apple.com/documentation/uikit/uinavigationbar/2908999-preferslargetitlesYou're using two scrollable views and one of them binds to navigation bar and another is not. During debug I've found out that the first scrollable view in hierarchy attached its
refreshControl
to navigation bar.
So, that's means we can fix it by putting some fake or dummy scrollable view somewhere on the bottom of hierarchy in order to it binds its refreshControl
to navigation bar first. Starting from iOS 11 any scrollable view may have refreshControl
and its "binded" even if you don't declare it explicitly.
In your case you might just add UIScrollView
before container in this way:
- View
-- Safe Area
-- UIScrollView (dummy)
-- ContainerView
---- TableView 1
---- TableView 2
...
@iiya OMG! The issue is solved by this method!! Thanks a lot!!!!
– himiyo3in
Nov 22 '18 at 8:37
@ilya ..Amazing solution along with description !!!
– SachinVsSachin
Nov 22 '18 at 9:30
add a comment |
Try this--
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
//Updated code.. this will fix it
self.tableView.addSubview(refreshControl)
}
Let us know .. is working ?
tableviewcontroller already haverefreshControl
property.
– Lal Krishna
Nov 22 '18 at 6:36
but this time new allocations has happened.. so there I have doubt over to added view in tableView..
– SachinVsSachin
Nov 22 '18 at 6:38
@SachinVsSachin Thank you for your advise, but it's not working...
– himiyo3in
Nov 22 '18 at 8:31
add a comment |
TableviewController 1
class TableViewController1: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView1.addSubview(refreshControl) // Added Line
}
TableviewController 2
class TableViewController2: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView2.addSubview(refreshControl) // Added Line
}
It's not working, but thank you for your advise!
– himiyo3in
Nov 22 '18 at 8:39
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%2f53424665%2fswift4uirefreshcontrol-indicator-appear-at-different-position%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
This happens because of combination of things.
You're using large headers for navigation controller. That makes
TableViewController
(actually any scrollable view) to put itsrefreshControl
on navigation bar . This behaviour was introduced in iOS 11 https://developer.apple.com/documentation/uikit/uinavigationbar/2908999-preferslargetitlesYou're using two scrollable views and one of them binds to navigation bar and another is not. During debug I've found out that the first scrollable view in hierarchy attached its
refreshControl
to navigation bar.
So, that's means we can fix it by putting some fake or dummy scrollable view somewhere on the bottom of hierarchy in order to it binds its refreshControl
to navigation bar first. Starting from iOS 11 any scrollable view may have refreshControl
and its "binded" even if you don't declare it explicitly.
In your case you might just add UIScrollView
before container in this way:
- View
-- Safe Area
-- UIScrollView (dummy)
-- ContainerView
---- TableView 1
---- TableView 2
...
@iiya OMG! The issue is solved by this method!! Thanks a lot!!!!
– himiyo3in
Nov 22 '18 at 8:37
@ilya ..Amazing solution along with description !!!
– SachinVsSachin
Nov 22 '18 at 9:30
add a comment |
This happens because of combination of things.
You're using large headers for navigation controller. That makes
TableViewController
(actually any scrollable view) to put itsrefreshControl
on navigation bar . This behaviour was introduced in iOS 11 https://developer.apple.com/documentation/uikit/uinavigationbar/2908999-preferslargetitlesYou're using two scrollable views and one of them binds to navigation bar and another is not. During debug I've found out that the first scrollable view in hierarchy attached its
refreshControl
to navigation bar.
So, that's means we can fix it by putting some fake or dummy scrollable view somewhere on the bottom of hierarchy in order to it binds its refreshControl
to navigation bar first. Starting from iOS 11 any scrollable view may have refreshControl
and its "binded" even if you don't declare it explicitly.
In your case you might just add UIScrollView
before container in this way:
- View
-- Safe Area
-- UIScrollView (dummy)
-- ContainerView
---- TableView 1
---- TableView 2
...
@iiya OMG! The issue is solved by this method!! Thanks a lot!!!!
– himiyo3in
Nov 22 '18 at 8:37
@ilya ..Amazing solution along with description !!!
– SachinVsSachin
Nov 22 '18 at 9:30
add a comment |
This happens because of combination of things.
You're using large headers for navigation controller. That makes
TableViewController
(actually any scrollable view) to put itsrefreshControl
on navigation bar . This behaviour was introduced in iOS 11 https://developer.apple.com/documentation/uikit/uinavigationbar/2908999-preferslargetitlesYou're using two scrollable views and one of them binds to navigation bar and another is not. During debug I've found out that the first scrollable view in hierarchy attached its
refreshControl
to navigation bar.
So, that's means we can fix it by putting some fake or dummy scrollable view somewhere on the bottom of hierarchy in order to it binds its refreshControl
to navigation bar first. Starting from iOS 11 any scrollable view may have refreshControl
and its "binded" even if you don't declare it explicitly.
In your case you might just add UIScrollView
before container in this way:
- View
-- Safe Area
-- UIScrollView (dummy)
-- ContainerView
---- TableView 1
---- TableView 2
...
This happens because of combination of things.
You're using large headers for navigation controller. That makes
TableViewController
(actually any scrollable view) to put itsrefreshControl
on navigation bar . This behaviour was introduced in iOS 11 https://developer.apple.com/documentation/uikit/uinavigationbar/2908999-preferslargetitlesYou're using two scrollable views and one of them binds to navigation bar and another is not. During debug I've found out that the first scrollable view in hierarchy attached its
refreshControl
to navigation bar.
So, that's means we can fix it by putting some fake or dummy scrollable view somewhere on the bottom of hierarchy in order to it binds its refreshControl
to navigation bar first. Starting from iOS 11 any scrollable view may have refreshControl
and its "binded" even if you don't declare it explicitly.
In your case you might just add UIScrollView
before container in this way:
- View
-- Safe Area
-- UIScrollView (dummy)
-- ContainerView
---- TableView 1
---- TableView 2
...
edited Nov 22 '18 at 7:45
answered Nov 22 '18 at 7:40
ilyailya
1,0151114
1,0151114
@iiya OMG! The issue is solved by this method!! Thanks a lot!!!!
– himiyo3in
Nov 22 '18 at 8:37
@ilya ..Amazing solution along with description !!!
– SachinVsSachin
Nov 22 '18 at 9:30
add a comment |
@iiya OMG! The issue is solved by this method!! Thanks a lot!!!!
– himiyo3in
Nov 22 '18 at 8:37
@ilya ..Amazing solution along with description !!!
– SachinVsSachin
Nov 22 '18 at 9:30
@iiya OMG! The issue is solved by this method!! Thanks a lot!!!!
– himiyo3in
Nov 22 '18 at 8:37
@iiya OMG! The issue is solved by this method!! Thanks a lot!!!!
– himiyo3in
Nov 22 '18 at 8:37
@ilya ..Amazing solution along with description !!!
– SachinVsSachin
Nov 22 '18 at 9:30
@ilya ..Amazing solution along with description !!!
– SachinVsSachin
Nov 22 '18 at 9:30
add a comment |
Try this--
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
//Updated code.. this will fix it
self.tableView.addSubview(refreshControl)
}
Let us know .. is working ?
tableviewcontroller already haverefreshControl
property.
– Lal Krishna
Nov 22 '18 at 6:36
but this time new allocations has happened.. so there I have doubt over to added view in tableView..
– SachinVsSachin
Nov 22 '18 at 6:38
@SachinVsSachin Thank you for your advise, but it's not working...
– himiyo3in
Nov 22 '18 at 8:31
add a comment |
Try this--
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
//Updated code.. this will fix it
self.tableView.addSubview(refreshControl)
}
Let us know .. is working ?
tableviewcontroller already haverefreshControl
property.
– Lal Krishna
Nov 22 '18 at 6:36
but this time new allocations has happened.. so there I have doubt over to added view in tableView..
– SachinVsSachin
Nov 22 '18 at 6:38
@SachinVsSachin Thank you for your advise, but it's not working...
– himiyo3in
Nov 22 '18 at 8:31
add a comment |
Try this--
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
//Updated code.. this will fix it
self.tableView.addSubview(refreshControl)
}
Let us know .. is working ?
Try this--
class TableViewController2: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
//Updated code.. this will fix it
self.tableView.addSubview(refreshControl)
}
Let us know .. is working ?
answered Nov 22 '18 at 6:33
SachinVsSachinSachinVsSachin
5,02112735
5,02112735
tableviewcontroller already haverefreshControl
property.
– Lal Krishna
Nov 22 '18 at 6:36
but this time new allocations has happened.. so there I have doubt over to added view in tableView..
– SachinVsSachin
Nov 22 '18 at 6:38
@SachinVsSachin Thank you for your advise, but it's not working...
– himiyo3in
Nov 22 '18 at 8:31
add a comment |
tableviewcontroller already haverefreshControl
property.
– Lal Krishna
Nov 22 '18 at 6:36
but this time new allocations has happened.. so there I have doubt over to added view in tableView..
– SachinVsSachin
Nov 22 '18 at 6:38
@SachinVsSachin Thank you for your advise, but it's not working...
– himiyo3in
Nov 22 '18 at 8:31
tableviewcontroller already have
refreshControl
property.– Lal Krishna
Nov 22 '18 at 6:36
tableviewcontroller already have
refreshControl
property.– Lal Krishna
Nov 22 '18 at 6:36
but this time new allocations has happened.. so there I have doubt over to added view in tableView..
– SachinVsSachin
Nov 22 '18 at 6:38
but this time new allocations has happened.. so there I have doubt over to added view in tableView..
– SachinVsSachin
Nov 22 '18 at 6:38
@SachinVsSachin Thank you for your advise, but it's not working...
– himiyo3in
Nov 22 '18 at 8:31
@SachinVsSachin Thank you for your advise, but it's not working...
– himiyo3in
Nov 22 '18 at 8:31
add a comment |
TableviewController 1
class TableViewController1: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView1.addSubview(refreshControl) // Added Line
}
TableviewController 2
class TableViewController2: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView2.addSubview(refreshControl) // Added Line
}
It's not working, but thank you for your advise!
– himiyo3in
Nov 22 '18 at 8:39
add a comment |
TableviewController 1
class TableViewController1: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView1.addSubview(refreshControl) // Added Line
}
TableviewController 2
class TableViewController2: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView2.addSubview(refreshControl) // Added Line
}
It's not working, but thank you for your advise!
– himiyo3in
Nov 22 '18 at 8:39
add a comment |
TableviewController 1
class TableViewController1: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView1.addSubview(refreshControl) // Added Line
}
TableviewController 2
class TableViewController2: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView2.addSubview(refreshControl) // Added Line
}
TableviewController 1
class TableViewController1: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView1.addSubview(refreshControl) // Added Line
}
TableviewController 2
class TableViewController2: UITableViewController {
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl?.addTarget(self, action: #selector(onRefresh), for: .valueChanged)
tableView2.addSubview(refreshControl) // Added Line
}
answered Nov 22 '18 at 7:22
Trupesh VaghasiyaTrupesh Vaghasiya
818
818
It's not working, but thank you for your advise!
– himiyo3in
Nov 22 '18 at 8:39
add a comment |
It's not working, but thank you for your advise!
– himiyo3in
Nov 22 '18 at 8:39
It's not working, but thank you for your advise!
– himiyo3in
Nov 22 '18 at 8:39
It's not working, but thank you for your advise!
– himiyo3in
Nov 22 '18 at 8:39
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%2f53424665%2fswift4uirefreshcontrol-indicator-appear-at-different-position%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
I guess you are missing to set the frame or offset for
UIRefreshControl
– Mukesh
Nov 22 '18 at 6:18