我是iphone开发的新手.我想在导航栏中设置一个活动指示器.我在导航栏下面看到我的活动指示器.我的代码在这里
- (IBAction) gomethod : (id) sender {
xxMapSubviewcontroller = [[XxMapSubviewcontroller alloc] init];
[self.navigationController pushViewController:xxMapSubviewcontroller animated:YES];
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame = CGRectMake(0.0, 0.0, 20.0, 20.0);
[activityIndicator startAnimating];
[xxMapSubviewcontroller.view addSubview:activityIndicator];
}
Run Code Online (Sandbox Code Playgroud)
如何在导航栏中设置我的活动指示器?请帮帮我.谢谢.
我需要在视图分页器文件中获取包含图像的页面指示符.这是我的代码.
public class IndicatorActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyPagerAdapter adapter = new MyPagerAdapter();
ViewPager myPager = (ViewPager) findViewById(R.id.pager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(0);
TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicat);
indicator.setViewPager( myPager );
}
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我得到一个错误 TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicat);
的TitlePageIndicator cannot be resolved to a type
.这是什么错误.我该如何解决?
这是我的xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/indicat"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
</LinearLayout> …
Run Code Online (Sandbox Code Playgroud) android activity-indicator android-view android-viewpager viewpagerindicator
正在使用的软件包:
"@react-native-community/datetimepicker": "^2.6.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-firebase/app": "^8.2.0",
"@react-native-firebase/auth": "^8.2.0",
"@react-navigation/drawer": "^5.8.5",
"@react-navigation/native": "^5.7.0",
"@react-navigation/stack": "^5.7.0",
"date-fns": "^2.14.0",
"react": "16.13.1",
"react-native": "0.63.0",
"react-native-gesture-handler": "^1.6.1",
"react-native-razorpay": "^2.1.35",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.1.1",
"react-native-screens": "^2.9.0",
"react-native-vector-icons": "^7.0.0"
Run Code Online (Sandbox Code Playgroud)
而 myActivityIndicator
被放置在一个屏幕组件中,如下所示:
import React from 'react'
import { View, Text, ActivityIndicator, StyleSheet, Image } from 'react-native'
export default function Loading({navigation}) {
return (
<View style={styles.container}>
<Image
style={styles.main_logo}
source={require('../assets/logo.png')}
/>
<Text style={styles.loading_text}>...Loading...</Text>
<ActivityIndicator animating={true} size="large" style={{opacity:1}} />
</View>
)
}
const styles = StyleSheet.create({
container: { …
Run Code Online (Sandbox Code Playgroud) 显示然后隐藏动画指示符/微调器GIF是向用户显示其操作有效以及在等待操作完成时发生某些事情的好方法 - 例如,如果操作需要从服务器加载某些数据(s )通过AJAX.
我的问题是,如果减速的原因是处理器密集的功能,gif会冻结.
在大多数浏览器中,GIF会在执行处理器饥饿功能时停止动画.对于用户来说,这看起来有些事情已经崩溃或发生故障,而实际上它正在工作.
注意:"这很慢"按钮会占用处理器一段时间 - 对我来说大约10秒钟,将根据PC规格而有所不同.您可以使用HTML中的"data-reps"attr更改它的功能.
如果JS保持处理器忙,有没有办法表明正在运行的进程没有冻结?如果没有办法制作动画片,我会依靠显示然后隐藏静态文字信息Loading...
或类似内容,但动画看起来更活跃.
如果有人想知道我为什么使用处理器密集型的代码而不是通过优化来避免问题:这很多都是复杂的渲染.代码非常高效,但它的功能很复杂,因此对处理器的要求总是很高.它只需要几秒钟,但这足以让用户感到沮丧,并且有很多研究可以追溯到很长一段时间,以证明指标对用户体验有利.
处理器繁重函数的gif微调器的第二个相关问题是,在一个同步集中的所有代码都运行之前,微调器实际上并不显示 - 这意味着它通常不会显示微调器,直到隐藏微调器为止.
setTimeout( function(){ ... },50);
以非常短的间隔显示指示符之后包装所有内容,以使其异步.这是有效的(见上面的第一个例子),但它不是很干净 - 我确信有更好的方法.我确信必须有一些标准的处理器密集型加载指标的方法,我不知道 - 或者只是使用Loading...
文本是正常的setTimeout
?我的搜索没有任何结果.我已经阅读了6或7个关于类似声音问题的问题,但它们都变得无关紧要.
编辑评论中的一些很棒的建议,以下是我确切问题的一些细节:
Loading...
文本,并给其他人一些现代的东西.javascript animated-gif css3 activity-indicator css-transitions
是否可以在Xcode6的启动屏幕中使用UIActivityIndicator
我试过但它没有动画,不确定它是否可能.
任何人都可以尝试这个或知道它是否可能?
谢谢-
我想知道如何在基于WebView的应用程序中实现activityIndicator,我写了下面的代码,但指标没有出现.
webview在本地加载文件,因此加载速度非常快,但是当它加载外部页面时加载速度很慢,我需要指标...
FirstViewController.h
#import <UIKit/UIKit.h>
@interface FirstViewController :
UIViewController <UIWebViewDelegate>{
IBOutlet UIWebView *webview1;
NSURL *urlLocation;
IBOutlet UIActivityIndicatorView *m_activity;
}
@property (nonatomic, retain) UIActivityIndicatorView *m_activity;
- (IBAction)searchbutton:(id)sender;
- (IBAction)home:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
FirstViewController.m
#import "FirstViewController.h"
@implementation FirstViewController
@synthesize m_activity;
// viewWillAppear loads every time younopen up this View
- (void)viewWillAppear:(BOOL)animated {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
urlLocation = [NSURL fileURLWithPath:filePath];
[webview1 loadRequest:[NSURLRequest requestWithURL:urlLocation]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
//Initialization code
m_activity = …
Run Code Online (Sandbox Code Playgroud) 我是iPhone开发的新手.我想设置一个活动指示器,它载在我的自定义按钮上.请指导我.(示例:App store - > Search - > Show 25 more(点击)).
我想将我的activityIndicator放置在需要编程的地方,但是我不知道怎么做。
我知道如何将其放在屏幕中央:
activityIndicator.center = self.view.center
Run Code Online (Sandbox Code Playgroud)
但是我想要这样的东西:
activityIndicator.activityIndicator(frame: CGRect(x: 100, y: 100, width: 100, height: 50))
Run Code Online (Sandbox Code Playgroud)
但是我似乎无法使它起作用。
我有一个ActivityIndicator,显示当fetch正在加载时,当触发componentDidMount时轮子消失,但是在布局中保留并清空块空间.我猜是如何卸载这个组件,但任何事情对我有用.
我目前正在使用这些版本:
react-native-cli: 2.0.1
react-native: 0.40.0
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码的一部分:
import React, { Component } from 'react';
import {
StyleSheet,
View,
... // Couple more components here
ActivityIndicator,
} from 'react-native';
import NewsList from './NewsList';
export default class HomeView extends Component {
constructor(props) {
super(props);
this.state = {
noticias: [],
animating: true,
};
}
componentDidMount(){
fetchFunction() // My fetch function here
.then(data => this.setState({ data:data }))
this.state.animating = false
}
render() {
return (
<View>
<NewsList data={data} /> // …
Run Code Online (Sandbox Code Playgroud) 我正在使用名为 selectedStream 的状态设置我的 flatlist 组件显示的数据。每次用户按下不同的组选项时,selectedStream 都会发生变化。我注意到平面列表需要 1-3 秒才能刷新当前已显示的所有帖子。我希望有一个加载指示器,以便当指示器消失时,列表已经正确显示新更新的数据。
<FlatList
maxToRenderPerBatch={5}
bounces={false}
windowSize={5}
ref={feedRef}
data={selectedStream}/>
Run Code Online (Sandbox Code Playgroud) javascript activity-indicator reactjs react-native react-native-flatlist
iphone ×3
react-native ×3
android ×2
ios ×2
javascript ×2
android-view ×1
animated-gif ×1
button ×1
css3 ×1
frame ×1
objective-c ×1
reactjs ×1
swift ×1
swift3 ×1
xcode ×1