我通过以下方式将默认标记添加到GoogleMap:
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.editMapMap)).getMap();
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(currentLocation.getCoordinate());
markerOptions.title(Utils.getLocationString(currentLocation.getCoordinate()));
markerOptions.snippet("Blah");
locationMarker = map.addMarker(markerOptions);
locationMarker.setDraggable(true);
Run Code Online (Sandbox Code Playgroud)
如何让标记始终显示标题和片段而不触摸?我也想禁用隐藏它们.
假设我有一个活动在屏幕上显示一些内容.我需要异步执行一些方法(asyncMethod),当它完成后,我需要在屏幕上更新数据.这是最正确和最简单的方法是什么?
目前我所知道的最简单的方法是使用线程:
new Thread(new Runnable() {
public void run() {
asyncMethod();
}
}).start();
Run Code Online (Sandbox Code Playgroud)
我熟悉AsyncTask,但它比使用线程更复杂,并且对于我需要异步运行的每个方法,需要创建新的AsyncTask,同时这会大大增加代码大小.
我想到了一些通用的AsincTask,它将方法作为参数而不是执行它,但据我所知,在Java中不可能将方法作为参数传递.
换句话说,我正在寻找异步执行方法的最紧凑(但正确)的方法.
我已经为我的UITableView添加了自定义背景图像,它显示正常.比,我从细胞中删除了任何背景颜色.现在我希望在桌子的背景图像上只看到单元格的文本,但是我看到了奇怪的行为.单元格采用表格背景图像的图案颜色,这样我就可以看到图片中的波形:
背景图像shell看起来像这样:
*注意在细胞下消失的白色圆圈!
我的代码如下:在viewDidLoad中我设置了表视图的背景图像:
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"general_bg.png"]];
Run Code Online (Sandbox Code Playgroud)
对于每个单元格我删除任何背景颜色,如下所示:
UIView *bckView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
bckView.backgroundColor = [UIColor clearColor];
cell.backgroundView = bckView;
cell.backgoundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(x,y,x1,y1)];
textLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:textLabel];
Run Code Online (Sandbox Code Playgroud)
我的iPhone应用程序使用位置服务.当我第一次安装并运行它时,它会显示一个对话框,询问用户是否希望暂时使用位置服务并立即消失.这种情况连续发生几次.
这是一个已知的错误还是我做错了什么?
我知道我可以使用标准的iOS本地化机制来本地化NSLocationAlwaysUsageDescription文本.由于我们使用自定义动态本地化机制,我想知道是否有另一种方法来翻译该字符串.我想在app start上编辑应用程序info.plist文件,但它似乎只读.
我可以使用应用程序更改此值吗?
我在使用"NSForegroundColorAttributeName"更改子字符串颜色时遇到问题.我很困惑,因为正在应用相同子字符串的其他属性(下划线).
还尝试使用弃用属性"UITextAttributeTextColor"和其他建议属性"kCTForegroundColorAttributeName"并获得相同的效果.
我正在为iOS 7编译.
NSString *freeText = [NSString stringWithFormat:@"(%@)", self.me.activity.text];
int lblMaxWidth = arrImgView.origin.x - WPRConstraints.BorderOffset;
int lblMaxHeight = self.activityView.size.height - WPRConstraints.BorderOffset * 2;
RevUILabel *addActivityLbl = [[RevUILabel alloc] initWithFontNameMultiLine:[WPRFonts LattoBold]
size:16
sizeConstrain:CGSizeMake(lblMaxWidth,lblMaxHeight)];
addActivityLbl.text = [NSString stringWithFormat:@"%@ %@", Translate(self.me.activity.activityKey), freeText] ;
addActivityLbl.textColor = BlackColor;
NSMutableAttributedString *str = [addActivityLbl.attributedText mutableCopy];
[str addAttribute:NSUnderlineColorAttributeName value:[UIColor redColor] range:[addActivityLbl.text rangeOfString:freeText]];
[str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:1] range:[addActivityLbl.text rangeOfString:freeText]];
[str addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:[addActivityLbl.text rangeOfString:freeText]];
addActivityLbl.attributedText = str;
addActivityLbl.frame = CGRectMake(WPRConstraints.BorderOffset,
WPRConstraints.BorderOffset,
addActivityLbl.size.width,
addActivityLbl.size.height);
[self.activityView addSubview:addActivityLbl];
Run Code Online (Sandbox Code Playgroud) 我需要为我的UINavigationBar按钮设置自定义颜色.我正在做以下事情(RGB func是一个定义):
- (void)viewWillAppear:(BOOL)animated
{
for (UIView *view in self.navigationController.navigationBar.subviews)
if ([[[view class] description] isEqualToString:@"UINavigationButton"])
[(UINavigationButton *)view setTintColor:RGB(22.0,38.0,111.0)];
}
Run Code Online (Sandbox Code Playgroud)
应用程序加载一切正常.离开视图后返回颜色返回默认值.
其次,我需要将相同的颜色设置为UISegmentedControl到按下的按钮.
如果我将任何ACCURACY设置为条件,则LocationManager需要很长时间才能开始更新位置:
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
provider = locationManager.getBestProvider(criteria, true);
locationManager.requestLocationUpdates(provider, 0, 0, this);
Run Code Online (Sandbox Code Playgroud)
如果我删除ACCURACY标志,它会立即启动但有时不准确.
如何让它立即开始更新并且准确度高?
是否可以始终在UISearchBar中显示文本光标(不仅仅是在触摸后)?
问题是有两个过程:
进程 C 是一个编译后的二进制文件,因此无法更改。
进程 C 必须从 A 接收并发送到 B。我将进程 B 绑定到端口 X。由于进程 A 每次总是从不同的随机端口发送,进程 C 向这些端口响应,进程 B 永远不会获取数据。
目前我的解决方案:
此解决方案有效,但不一致。
所以问题是:是否有可能从特定端口发送到本地主机 UDP 数据包而不绑定到它?也许其他一些解决方案?
这是当前状态的图表:
我正在使用 CLLocation 机制来获取 iPhone 中的坐标。我从“定位我”的例子中获取了一个例子,并对其进行了一些扩展。但是我提出了准确性问题。
那么问题来了,有没有办法让iPhone使用GPS而不是三角天线来获取位置呢?
很高兴知道是否有办法提高使用天线时的精度,但到目前为止我得到的最好结果是 65 米。
iphone ×6
objective-c ×6
xcode ×4
android ×3
java ×3
c ×2
google-maps ×2
ios ×2
asynchronous ×1
cocoa-touch ×1
core-text ×1
enums ×1
gps ×1
ios8 ×1
linux ×1
localization ×1
sockets ×1
string ×1
udp ×1
uisearchbar ×1
uitableview ×1