我可以在我的iPhone应用程序中成功推送下一个视图.但是,导致下一个视图检索数据以填充UITableViews,有时等待时间可能是几秒或稍长,具体取决于连接.
在此期间,用户可能认为应用程序已冻结等.因此,为了解决这个问题,我认为实施UIActivityIndicators将是让用户知道应用程序正在运行的好方法.
有人能告诉我在哪里可以实现这个吗?
谢谢.
pushDetailView方法
- (void)pushDetailView {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//load the clicked cell.
DetailsImageCell *cell = (DetailsImageCell *)[tableView cellForRowAtIndexPath:indexPath];
//init the controller.
AlertsDetailsView *controller = nil;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
controller = [[AlertsDetailsView alloc] initWithNibName:@"DetailsView_iPad" bundle:nil];
} else {
controller = [[AlertsDetailsView alloc] initWithNibName:@"DetailsView" bundle:nil];
}
//set the ID and call JSON in the controller.
[controller setID:[cell getID]];
//show the view.
[self.navigationController pushViewController:controller animated:YES];
Run Code Online (Sandbox Code Playgroud) 我有显示一个恼人的问题UITableViewCell与UIActivityIndicatorView内部.我的tableView委托加载了部分数据.最后一个单元格始终指示加载过程,而未加载新部分.加载从tableView: willDisplayCell: forRowAtIndexPath:iOS 5(或iOS 5模拟器)中的.So 开始,它完美地运行,但在iOS 6(或iOS 6模拟器)中UIActivityIndicatorView仅首次显示.也许有些东西因iOS 6或iOS 6漏洞而被弃用?
这是我的dataSource:
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
UITableViewCell* cell = nil;
if (_callback != nil && !_noMoreBooks && indexPath.row == [_books count])
{
cell = [tableView dequeueReusableCellWithIdentifier:LTTableViewLoadMoreCellIdentifier];
if (cell == nil)
{
cell = [[[LTLoadMoreCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:LTTableViewLoadMoreCellIdentifier] autorelease];
[(LTLoadMoreCell*)cell setRowTag:-1];
}
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:LTTableViewCellIdentifier];
if (cell == nil)
{
cell = [[[LTBookCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LTTableViewCellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleGray; …Run Code Online (Sandbox Code Playgroud) 我有一个水平集合视图,它有 20 个带有 UIImageView 的单元格我只想显示活动指示器,直到图像下载完成。我正在使用新的 SDWebImage 库,其中我们的方法为sd_setImageWithURL 直到现在我正在做的是
__block UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.center = cell.photoOneImageView.center;
activityIndicator.hidesWhenStopped = YES;
[cell.photoOneImageView sd_setImageWithURL:[NSURL URLWithString:@"https://scontent-sjc.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/p480x480/11073324_10153728863852926_4010319763478440264_n.jpg?oh=590934059508b7da235a46fc39e08063&oe=55B61458"]
placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];
}];
[cell.photoOneImageView addSubview:activityIndicator];
[activityIndicator startAnimating];
Run Code Online (Sandbox Code Playgroud)
我在cellForItemAtIndexPath方法中编写此代码它有时会在 1 个单元格上显示多个指标,有时当我们水平滚动集合视图时,它们也不会删除。
我看到了这个https://github.com/rs/SDNetworkActivityIndicator但我无法使用它。没有运气。当图像完成指示器消失时,是否有人在 tebleview 单元格或集合视图单元格中实现了活动指示器。请帮忙。任何帮助将不胜感激。谢谢
objective-c uiactivityindicatorview ios sdwebimage uicollectionview
我有 UITableView,其中每个单元格都有一个 UIImage 并且图像是使用 JSON 从 API 下载的。
我通过后台线程处理初始图像和数据。然而,当用户在表格视图中向下滚动时,其他单元格的图像开始下载,因此这些单元格需要一些刷新。
我想在 UIImageView 中添加一个 ActivityIndicator,这样用户就会注意到正在下载图像。
附加信息,UIImageView 位于 UIStackView 内。想过isHidden方法,没能实现。
感谢您的时间。
uitableview activity-indicator uiactivityindicatorview ios swift
我有一个显示网络视图的基本列表。我想添加一个在网页加载时显示的活动指示器。这是我创建的代码。
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
var url: String
// makeUIView func
func makeUIView(context: Context) -> WKWebView {
guard let url = URL(string: self.url) else {
return WKWebView()
}
let request = URLRequest(url: url)
let wkWebView = WKWebView()
wkWebView.load(request)
return wkWebView
}
// updateUIView func
func updateUIView(_ uiView: WKWebView, context: Context) {
}
}
struct WebView_Preview: PreviewProvider {
static var previews: some View {
WebView(url: "https://www.google.com")
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你!
我现在在推送另一个视图控制器之前启动活动指示器,但它没有开始为活动指示器设置动画.
[activityindicator startanimating];
[self.navigationcontroller pushviewcontroller:viewcontroller animated:YES];
[activityindicator stopanimating];
Run Code Online (Sandbox Code Playgroud) 我有一个标签栏应用程序.我有两个问题.
使用应用程序的默认图像可以使应用程序在显示图像时在后台初始化自身(MainView.xib中显示的第一个视图)?
触摸应用程序中的第二个选项卡,应用程序将数据加载到UITableView.这需要一些时间(从互联网上获取一些数据),因此从第一个选项卡到第二个选项卡,在第二个选项卡中显示表之前会有一段延迟.我想显示正在填充的一段UIActivityIndicatorView时间UITableView,然后希望在
完成加载UIActivityIndicatorView时消失UITableView.我怎样才能做到这一点?
我有一个方法,在我的app委托中,被调用来从Web服务器提取信息.有没有办法轻松地将UIActivityViewIndicators纳入app委托?到目前为止我在网上找到的所有内容都显示需要将指标添加为子视图.这可行吗?如果是这样,你能指出我在哪里找到这个正确的方向吗?
[编辑]我正在使用故事板而不是xibs.
为了使UIActivityIndicatorView成为左视图,我要做的就是
searchField.leftView = self.progressIndicator;
Run Code Online (Sandbox Code Playgroud)
但是,如果我将leftView更改为rightView,则指示器不会显示。我该如何解决这个问题?
如何获得NSOperationQueue的完成块,这里我想从所有操作的开始到结束旋转活动指示器.
NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init];
// Set the max number of concurrent operations (threads)
[operationQueue setMaxConcurrentOperationCount:3];
[operationQueue addOperations:@[operation, operation1, operation3,...] waitUntilFinished:NO];
Run Code Online (Sandbox Code Playgroud)
谢谢.
ios ×4
iphone ×4
objective-c ×4
uitableview ×4
cocoa-touch ×2
ios5 ×1
ios6 ×1
sdwebimage ×1
spinner ×1
swift ×1
swiftui ×1
uitextfield ×1
uiview ×1
webview ×1
xcode11 ×1