如何在UIActivityIndicatorView旋转时禁用所有输入?
谢谢
我使用UIActivityViewController来显示共享.在我选择邮件应用程序的列表中,主题和正文设置正确,Gmail应用程序中的位置为空.
- (void)shareAVideoWithSubject:(NSString*)subject Link:(NSString *)string onViewController:(UIViewController *)viewController fromView:(UIView *)view {
_activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[string]
applicationActivities:nil];
_activityViewController.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList, UIActivityTypeAirDrop];
[_activityViewController setValue:subject forKey:@"subject"];
UIWindow *window = [[[UIApplication sharedApplication] delegate]window];
//if iPhone
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
if(!viewController){
viewController = ((SWRevealViewController*)window.rootViewController).presentedViewController;
}
[viewController presentViewController:_activityViewController
animated:YES
completion:nil];
}
//if iPad
else
{
// Change Rect to position Popover
popup = [[UIPopoverController alloc] initWithContentViewController:_activityViewController];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:view];
[popup presentPopoverFromBarButtonItem:barButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
我在StackOverFlow上查看了以下两个问题.
这些不是我的问题的答案,因为他们在列表中添加了新的活动,而我希望iOS显示所有可共享的应用程序.在这种情况下,Gmail共享正在变空. …
我正在处理以下代码,并尝试在页面加载时在视图中显示活动指示器.
我试图实现WKNavigationDelegate方法,但我失败了,因为没有显示.
对于如何解决这个问题,有任何的建议吗?
我没有在任何地方设置SupportWebView视图委托,但我不知道如何在swift中执行它.
import UIKit
import WebKit
class SupportWebView: UIViewController, WKNavigationDelegate {
@IBOutlet var containerView : UIView? = nil
var webView: WKWebView?
override func loadView() {
super.loadView()
self.webView = WKWebView()
self.view = self.webView
}
override func viewDidLoad() {
super.viewDidLoad()
var dataManager = DataManager.sharedDataManager()
var url = dataManager.myValidURL
var req = NSURLRequest(URL:url!)
self.webView!.loadRequest(req)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func webView(webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { …Run Code Online (Sandbox Code Playgroud) 我想向alertview显示消息:"正在加载数据"和旋转活动指示器.我怎样才能做到这一点?
我有一个包含两个视图的视图.其中一个视图包含两个按钮和一些文本标签.另一个,alpha设置为0.25,有一个UIActivityIndicatorView告诉用户应用程序正在工作,他必须等到它完成.如果用户在UIActivityIndicatorView旋转时触摸按钮,则当UIActivityIndicatorView停止时,应用记住用户操作并响应它.如何丢弃UIActivityIndicatorView正在旋转时发生的用户交互?
谢谢阅读.
PD:就像在这个帖子中评论一样,我更喜欢不使用任何模态解决方案.
编辑:
我目前正在使用此代码,但它无法正常工作.
- (void)viewDidAppear:(BOOL)animated {
// The view appears with an UIActivityIndicatorView spinning.
[self showResults]; // The method that takes a long time to finish.
[self.activityIndicator stopAnimating];
// When the showResults method ends, the view shows the buttons to the user.
[self.activityIndicatorView setHidden:YES];
[self.menuButton setEnabled:YES];
[self.menuButton setUserInteractionEnabled:YES];
[self.playButton setEnabled:YES];
[self.playButton setUserInteractionEnabled:YES];
[self.view setUserInteractionEnabled:YES];
[self.interactionView setUserInteractionEnabled:YES];
}
Run Code Online (Sandbox Code Playgroud) 我目前UIAlertController正在屏幕上显示.警报视图应仅显示2个元素,标题和UIActivityIndicatorView警报中心.以下是显示警报及其元素的功能.
func displaySignUpPendingAlert() -> UIAlertController {
//Create the UIAlertController
let pending = UIAlertController(title: "Creating New User", message: nil, preferredStyle: .Alert)
//Create the activity indicator to display in it.
let indicator = UIActivityIndicatorView(frame: CGRectMake(pending.view.frame.width / 2.0, pending.view.frame.height / 2.0, 20.0, 20.0))
indicator.center = CGPointMake(pending.view.frame.width / 2.0, pending.view.frame.height / 2.0)
//Add the activity indicator to the alert's view
pending.view.addSubview(indicator)
//Start animating
indicator.startAnimating()
self.presentViewController(pending, animated: true, completion: nil)
return pending
}
Run Code Online (Sandbox Code Playgroud)
但是,活动指示器不会显示在视图的中心,实际上它显示在屏幕的右下方,远离视图.这是什么原因?
编辑:我知道我可以硬编码指标位置的数字,但我希望警报可以在多个屏幕尺寸和方向的多个设备上工作.
对于Mac OS X,是否有像"UIActivityIndicatorView for iOS"的"NSActivityIndicatorView"?
如何在长时间的活动中展示旋转的"装备"?
为什么以下代码不能将活动指示器定位到其超级视图的中心:
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[self.mysuperview addSubview:activityIndicator];
[activityIndicator addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"|-(>=20)-[view(==100)]-(>=20)-|"
options:NSLayoutFormatAlignAllCenterX | NSLayoutFormatAlignAllCenterY
metrics:nil
views:@{@"view" : self.mysuperview}]];
Run Code Online (Sandbox Code Playgroud)
活动指示器位于左上角的某个位置,绝对不在中心位置.
==================更新:找到解决方案:我必须在创建指标后关闭自动调整约束,然后在给定工作的所有解决方案中关闭:
[activityIndicator setTranslatesAutoresizingMaskIntoConstraints:NO];
Run Code Online (Sandbox Code Playgroud)
我在@Vignesh给出的链接上找到了它,所以我接受他/她的回答.
在我的应用程序中,我想在UItableview下添加活动指示器,其中tableview将滚动但我不知道如何在那里添加活动指示器.
详细说明,当我将完成tableview的滚动时,为了获得更多数据,我必须通过活动指示器设置刷新选项.
我已经在tableview的顶部尝试了它并且它工作但我不知道如何将它添加到tableview下面.这是一些示例代码..
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if (isLoading) return;
isDragging = YES;
refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)];
refreshHeaderView.backgroundColor = [UIColor clearColor];
refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)];
refreshLabel.backgroundColor = [UIColor clearColor];
refreshLabel.font = [UIFont boldSystemFontOfSize:12.0];
refreshLabel.textAlignment = UITextAlignmentCenter;
refreshArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"refresharrow.png"]];
refreshArrow.frame = CGRectMake((scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT - 27) / 2,
(scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT - 44) / 2,
27, 44);
refreshSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
refreshSpinner.frame = CGRectMake((scrollView.contentOffset.y …Run Code Online (Sandbox Code Playgroud) 我希望在加载数据时(在另一个线程中)在uitableview上显示活动指示器.所以在UITableViewController的ViewDidLoad方法中:
-(void)viewDidLoad
{
[super viewDidLoad];
//I create the activity indicator
UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[ac startAnimating];
//Create the queue to download data from internet
dispatch_queue_t downloadQueue = dispatch_queue_create("PhotoDownload",NULL);
dispatch_async(downloadQueue, ^{
//Download photo
.......
.......
dispatch_async(dispatch_get_main_queue(), ^{
......
......
[ac stopAnimating];
});
});
.......
Run Code Online (Sandbox Code Playgroud)
为什么活动指示器不会显示在表格视图上?我怎样才能实现它?
ios ×8
iphone ×3
uitableview ×2
autolayout ×1
cocoa ×1
cocoa-touch ×1
delegates ×1
gmail ×1
ipad ×1
macos ×1
objective-c ×1
swift ×1
uialertview ×1
uiscrollview ×1
uiview ×1
wkwebview ×1