我有一个NSString以a JSON的形式存储数组NSString.被NSString调用colorArray的值为:
[{ "color":"Red" },{ "color":"Blue" },{ "color":"Yellow"}];
Run Code Online (Sandbox Code Playgroud)
我还有一个tableview,我想导入数组,以填充表.如果我将数据加载tableData到如下所示的数组中,该表有效,但我无法弄清楚如何将其NSString转换为可用于填充tableData如下所示的数组的数组...
有人有想法吗?非常感谢!
- (void)viewDidLoad
{
[super viewDidLoad];
// Initialize table data
tableData = [NSArray arrayWithObjects:@"Red", @"Blue", @"Yellow", nil];
}
Run Code Online (Sandbox Code Playgroud) 我有一张包含很多列的表格.列的总数尚未指定,并将定期更改.
在我的插入查询中,我只需要在表中放入两个值.所有其他值将是''.有没有办法只指定第一个字段,而不必包含'','','',''......?请看下面的例子:
我想要这个:
$query = mysql_query("INSERT INTO table VALUES('','$id')");
Run Code Online (Sandbox Code Playgroud)
而不是这个:
$query = mysql_query("INSERT INTO table VALUES('','$id','','','','','',''......and on and on...)");
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?谢谢!
我想在我正在显示的地图上单击DetailDisclosure时切换视图.我目前的代码如下:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
DetailViewController *detailViewController = [[DetailViewController alloc]
initWithNibName:@"DetailViewController" bundle:nil];
detailViewController.title = dictionary[@"placeLatitude"]
[self.navigationController pushViewController:detailViewController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我可以用这个推送到视图控制器,但我还没弄明白如何强制它从用于生成地图的JSON数组中拉出细节.我正在拉这样的数据来生成地图:
for (NSDictionary *dictionary in array)
{
// retrieve latitude and longitude from the dictionary entry
location.latitude = [dictionary[@"placeLatitude"] doubleValue];
location.longitude = [dictionary[@"placeLongitude"] doubleValue];
//CAN I LOAD THE TITLE/ID OF THE LOCATION HERE?
Run Code Online (Sandbox Code Playgroud)
我知道我有点偏离目标.也许只是向正确的方向踢一脚可能有所帮助.谢谢!
好的,所以我一直在寻找对这个问题的充分回应.我有一个navigator.geolocation.getCurrentPosition用于获取用户位置的Web应用程序.
三星Galaxy设备上的本机浏览器几乎总是遇到getCurrentPosition代码问题.我已尝试使用回调和超时的此代码的各种变体,但它始终是相同的问题.很多人都记录了这个问题,有些人表示重启设备会起作用(有时重启确实有效,但并非总是如此 - 并且告诉用户重启设备的警报似乎超出了一定程度).
有没有人想出一个使用getCurrentPosition在三星Galaxy设备上工作的万无一失的方法?这是我正在使用的...
<script>
$(document).ready(function(){
if( navigator.geolocation ) {
navigator.geolocation.getCurrentPosition( success, fail );
}
else {
alert("Sorry, your browser does not support geolocation services.");
}
function success(position) {
window.location = "mobile_set_coordinates.php?user_lat=" + position.coords.latitude +
"&user_lon=" + position.coords.longitude + "&accuracy=" + position.coords.accuracy;
}
function fail() {
// Could not obtain location
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
此外,这里还有一个关于该问题的讨论链接:https://groups.google.com/forum/#!topic/phonegap/ESrHAjFHgFU
我想有一个iOS日期选择器,允许用户选择一周中的某一天和时间.例如:周三中午12:00.我不需要像下面那样显示月份或月份.有谁知道如何让用户只设置一周中的一天和时间?谢谢!

我有一个纬度和经度坐标,我想集中我的地图.它们存储为NSStrings并转换为以下位置:
NSString *placeLatitude = [elementCoords objectForKey:@"placeLatitude"];
NSString *placeLongitude = [elementCoords objectForKey:@"placeLongitude"];
CLLocationCoordinate2D location;
location.latitude = [placeLatitude doubleValue];
location.longitude = [placeLongitude doubleValue];
Run Code Online (Sandbox Code Playgroud)
我如何修改以下内容以不关注用户的当前位置,而是关注上面指定的纬度和经度?
MKCoordinateRegion mapRegion;
mapRegion.center = mapView.userLocation.coordinate;
mapRegion.span.latitudeDelta = 0.05;
mapRegion.span.longitudeDelta = 0.05;
Run Code Online (Sandbox Code Playgroud) 我正在构建一个可以在iPhone上打开全屏的网络应用程序,并且正在关注Facebook移动网站的代码,可以在以下网址找到:https://developers.facebook.com/docs/guides/mobile/web/
当我尝试使用Facebook登录页面登录时,单击"登录"按钮后,我得到一个空白的白色屏幕.用户登录但是..我知道这一点,因为如果我关闭并重新打开Web应用程序,我会检查登录状态并尝试获取一些用户信息,并且它工作正常.
我在这里见过其他人:FB登录后通过网络应用程序显示空白屏幕?
似乎有人确定了一种解决方法,但我无法让它发挥作用.我使用的代码是:
function loginUser() {
FB.login(function(response) { }, {scope:'email'});
}
Run Code Online (Sandbox Code Playgroud)
其他人表示我需要在这里使用解决方法:
login({scope:'email', redirect_uri:'where_to_go_when_login_ends'})
Run Code Online (Sandbox Code Playgroud)
有谁知道如何合并这些代码以使其工作?
谢谢!
我想知道是否有办法在mysql中选择一部分列.例如,我想从我的表中选择以"_sep_2012"结尾的所有统计信息.这将使我能够访问1_sep_2012,2_sep_2012,3_sep_2012等...有没有办法做到这一点?
<?php
$query=mysql_query("SELECT %_sep_2012% FROM statistics WHERE id = '$id'");
$array = mysql_fetch_row($query);
$monthly_total = $array[0];
echo "$monthly_total";
?>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.谢谢!
我想在viewController出现时获取用户的坐标.我需要几个viewControllers中的位置,所以我将locationManager放在appDelegate中.我的问题是,在第一个viewDidAppear上,尚未找到坐标.我该怎么做才能改变这个?谢谢你们!!!
我的AppDelegate有这个:
- (NSString *)getUserCoordinates
{
NSString *userCoordinates = [NSString stringWithFormat:@"latitude: %f longitude: %f",
locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude];
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];
return userCoordinates;
}
Run Code Online (Sandbox Code Playgroud)
我的viewController获取坐标:
- (void)viewDidAppear
{
NSString *userCoordinates =[(PDCAppDelegate *)[UIApplication sharedApplication].delegate
getUserCoordinates];
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在单个View Controller中执行两个警报的微笑任务.下面的代码工作正常,但我如何在View Controller的其他地方创建它的另一个实例.我担心如果我复制代码,我的buttonIndex将不知道它正在响应哪个警报.有任何想法吗?谢谢!
-(void)alertChoice
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message" delegate:self
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Confirm", nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
{
//do something
}
}
Run Code Online (Sandbox Code Playgroud)