假设我有一个格式为"name_surname"的字符串.我的意思是有2个动态部分,它们之间是下划线.我想将它们分开,并在变量中包含左侧部分(名称),在另一个变量中包含右侧(姓氏).
基本上我想要反过来: String temp=name+"_"+surname;
当从一个视图移动到另一个视图时,我想在我的第二个视图中,只要下载图像以查看微调器(这样第二个视图将立即打开而不需要任何时间,并且用户等待微调器完).
这是我的代码:
在第二个视图中,打开的视图:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIActivityIndicatorView *spinner=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.center=CGPointMake(160.0,240.0 );
spinner.hidesWhenStopped=YES;
[self.view addSubview:spinner];
[spinner startAnimating];
NSString *urlString=[NSString stringWithFormat:@"http://mysite.com/projects/test/test.jpg"];
NSLog(@"URL is:%@",urlString);
NSURL *url=[NSURL URLWithString:urlString];
[more_info_image setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:url]]];
[spinner stopAnimating];
}
Run Code Online (Sandbox Code Playgroud)
我根本看不到旋转器.我不认为这是因为我的互联网连接太胖了.另一方面,当按下按钮并等待视图打开时,我看到一点延迟 - 就像它试图下载图像的时候一样.
我想打开视图,拥有微调器,下载图像然后让微调器消失.
我必须改变什么吗?
我正在学习本教程: 入门并正确运行了示例.
我现在想添加移动添加特性,我按照本教程: FB移动安装广告
在step1中它说:
Set up your app to measure mobile app install ads
Run Code Online (Sandbox Code Playgroud)
一步一步,我评论我已经做了什么:
1.You need to integrate Facebook's latest SDK -->DONE with the tutorial getting started
2.For iOS 3.0 or greater, add the following to your UIApplicationDelegate applicationDidBecomeActive selector:
[FBSettings publishInstall:YOUR_APP_ID];-->DONE
I have added:
[FBSettings publishInstall:@"220............"]; in my appdelegate.m and imported the <FacebookSDK/FacebookSDK.h>
Run Code Online (Sandbox Code Playgroud)
然后是问题所在:
3. You can confirm that your app is correctly configured in the App Dashboard, or go directly there at https://developers.facebook.com/apps/YOUR_APP_ID. You should …Run Code Online (Sandbox Code Playgroud) 正如标题所说,无论我给出什么坐标,我都会看到相同的位置.
这是我的代码:
我正在使用故事板,我的视图中有一个子视图.子视图的类型为GMSMapView,并且链接正确.
.H
@property (strong, nonatomic) IBOutlet GMSMapView *mymap;
Run Code Online (Sandbox Code Playgroud)
.M
@implementation DealViewController
{
GMSMapView *mapView_;
}
@synthesize mymap=_mymap;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view layoutIfNeeded];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
longitude:151.2086
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 0, 300, 300) camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.mapType = kGMSTypeSatellite;
mapView_.delegate = self;
self.mymap=mapView_;
}
Run Code Online (Sandbox Code Playgroud)
我也试过这个,但我得到了同样的结果:
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
Run Code Online (Sandbox Code Playgroud)
上面有什么问题?
我在SO上看到了所有类似的问题,我在其他活动中使用了AsyncTask,但只有这一个没有调用onPostexecute.
这是我的代码在几小时后尝试.
class GetCamera1Task extends AsyncTask<Void, Void, Integer> {
private final ProgressDialog dialog = new ProgressDialog(
CameraGallery.this);
@Override
protected void onPreExecute() {
this.dialog.setMessage("Loading...");
this.dialog.show();
}
protected void onPostExecute(int result) {
System.out.println("onPostExecute");
this.dialog.dismiss();
}
@Override
protected Integer doInBackground(Void... params) {
// TODO Auto-generated method stub
bitmapResult1 = getBitmapFromURL(url[0]);
bitmapResult2 = getBitmapFromURL(url[1]);
}
System.out.println("should return");
return 1;
}
}
Run Code Online (Sandbox Code Playgroud)
其中所有变量都是全局变量.正在打印应该返回但是没有调用onPost执行.
我也试过我的onBackground返回null和sceleton如下:
class GetCamera1Task extends AsyncTask<Void, Void, Void> {
protected void onPostExecute() {
}
protected Integer doInBackground(Void... params) {
... return null;
} …Run Code Online (Sandbox Code Playgroud) 为什么这个for循环不能遍历所有项目:
temp = 0
for br in my_list :
temp +=1
#other code here
#my list is not used at all, only br is used inside here
my_list.remove(br)
print temp
assert len(my_list) == 0 , "list should be empty"
Run Code Online (Sandbox Code Playgroud)
因此,断言开火了.然后我添加了临时计数器,我确实看到尽管我的列表有202个元素,但for循环只处理了101个元素.这是为什么?
我有来自此格式的网址的回复.
'history': {'all': [[u'09 Aug', 1,5'],[u'16 Aug', 2, 6]]}
Run Code Online (Sandbox Code Playgroud)
代码是:
response = urllib.urlopen(url)
data = json.loads(response.read())
print data["fixture_history"]['all']
customObject = MyObject (
history = data["history"]['all']
)
Run Code Online (Sandbox Code Playgroud)
打印工作但在我的自定义类中我看到此错误:
history = data["history"]['all']
TypeError: 'module' object is not callable
Run Code Online (Sandbox Code Playgroud)
我的班级是:
class MyObject:
#init
def _init_(self,history):
self.hstory = history
Run Code Online (Sandbox Code Playgroud) 我已经读过这个但它似乎对我不起作用 -
>>> dict = {}
>>> dict[ "a" ] = set(("1111","test1"))
>>> dict
{'a': set(['1111', 'test1'])}
>>> dict[ "a" ].add( ("2222","test2"))
>>> dict
{'a': set(['1111', 'test1', ('2222', 'test2')])}
Run Code Online (Sandbox Code Playgroud)
我也期待第一个看起来像一个元组 - 为什么分裂?
我想做什么:
>>> for key,val_set in dict.items() :
... for val in val_set :
... print val
...
1111
test1
('2222', 'test2')
Run Code Online (Sandbox Code Playgroud)
打印2件不是三件.
我有一个CustomClass对象向量- 有一个字符串字段调用name.如何set在C++中创建这些名称?
如果我这样做:
std::vector<CustomClass> vec ;
// .... populate with data
std::set< std::string> myset( vec.begin(), vec.end() ) ;
Run Code Online (Sandbox Code Playgroud)
编译器当然会抱怨,但是如何"应用"一个函数,以便我从向量的每个元素中得到"vec.name"?
我正在使用C++ 11.
我已经实现了一个扩展视图的新ImageLoaderView,如果我以编程方式设置xml,则代码可以正常工作.但由于这似乎很难,我试图让它在我的res布局文件夹中的xml工作,但我收到一个错误.以下是我的代码.
LoaderImageView:
package com.anon.android.test;
import java.io.IOException;
import java.net.MalformedURLException;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.os.Handler.Callback;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
/**
* Free for anyone to use, just say thanks and share :-)
* @author Blundell
*
*/
public class LoaderImageView extends LinearLayout{
private static final int COMPLETE = 0;
private static final int FAILED = 1;
private Context mContext;
private Drawable mDrawable;
private ProgressBar mSpinner;
private ImageView mImage;
/**
* This …Run Code Online (Sandbox Code Playgroud) 在以下代码中,
float i = Float.parseFloat(a);
float j = Float.parseFloat(b);
double div = (double)j/i;
float theta = (float) Math.atan(Math.toRadians(div));
Run Code Online (Sandbox Code Playgroud)
theta获得错误的价值.到目前为止,我可以看到,它总是计算Math.tan(我也尝试了这个,它给了我相同的结果).所以,即使我写Math.tan或Math.atan,我得到相同的结果.
谁能帮我?
具体例子:
i,j----> theta I get:
3,4-----> 0.023 while the correct one is arctan(4/3)=53.13 not tan(4/3)=0.023
3,6-----> 0.052 while the correct one is arctan(9/3)=71.56 not tan(9/3)=0.052
Run Code Online (Sandbox Code Playgroud) 我有一个UImageView初始尺寸设置xib为:
Y:0,身高:406.
在viewDidLoad,根据我使用此代码的条件:
self.mainAdImg.frame = CGRectMake(self.mainAdImg.frame.origin.x, self.mainAdImg.frame.origin.y + OFFSET, self.mainAdImg.frame.size.width, self.mainAdImg.frame.size.height);
Run Code Online (Sandbox Code Playgroud)
哪里 mainAdImg is the UIImageView, and OFFSET is 20.0f
所以,我希望,图像会下降20.0.
相反,新值变为:
Y : 20 (correct), height: 426 (not expected)
Run Code Online (Sandbox Code Playgroud)
为什么高度变化?
编辑:
我没有使用autolayout.
我记录原点,高度像这样:
NSLog(@" Y : %f, height : %f",self.mainAdImg.frame.origin.y,self.mainAdImg.frame.size.height);
Run Code Online (Sandbox Code Playgroud) 我已经看到了类似的答案,但我似乎无法通过查看这些例子(例如这个或那个)来解决我的问题.
所以,我有这个.
啊
#ifndef INCLUDE_CLASS_NAME
#define INCLUDE_CLASS_NAME
#include <B.h>
using namespace C;
D::DPtr myvariable; <-- Error in here
#endif
Run Code Online (Sandbox Code Playgroud)
在包括Bh我有这个:
namespace C{
namespace E{
class D
{
public:
typedef shared_ptr<D> DPtr;
}
} //end of namespace E
} // end of namespace C
Run Code Online (Sandbox Code Playgroud)
为什么我在上述行中收到此错误:
'D' does not name a type
Run Code Online (Sandbox Code Playgroud)
我包含.h文件,它定义了类.我错过了什么?