所以我有两张桌子:
表 uno:
id | gender | lf
-------------------------
abc | 1 | 2
cde | 2 | 1
efg | 1 | 2
Run Code Online (Sandbox Code Playgroud)
表二人组:
id1 | id2
-------------------------
abc | cde
Run Code Online (Sandbox Code Playgroud)
我的工作(到目前为止)查询从表uno中精确选择了2行:
(SELECT
*
FROM
uno
WHERE gender = 1
AND lf = 2
ORDER BY RAND()
LIMIT 1)
UNION
(SELECT
*
FROM
uno
WHERE gender = 2
AND lf = 1
ORDER BY RAND()
LIMIT 1)
Run Code Online (Sandbox Code Playgroud)
哪个回报:
id | gender | lf
------------------------- …Run Code Online (Sandbox Code Playgroud) 在io7中,视图顶部的状态栏是一场噩梦.我真的设法让它工作,所以它将被放置在视图上方.我这样做:
- (void)viewDidLoad
{
[super viewDidLoad];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
self.view.backgroundColor=[UIColor colorWithRed:(152/255.0) green:(204/255.0) blue:(51/255.0) alpha:1] ;
CGRect frame = self.topNav.frame; frame.origin.y = 20;
self.topNav.frame = frame;
}
....
}
Run Code Online (Sandbox Code Playgroud)
现在我的状态栏位于我的导航栏上方.
但是当谈到调用的UIImagePickerController东西是不同的时.上面的代码没有任何效果.我试着这样做:
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
CGRect frame = self.imagePickerController.frame; frame.origin.y = 20;
self.imagePickerController.frame = frame;
}
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
self.imagePickerController = imagePickerController;
self.imagePickerController.allowsEditing=YES;
....
} …Run Code Online (Sandbox Code Playgroud) 祝你有快乐的一年!
我遇到以下问题.第一个逻辑:
从服务器获取json.Json值始终是一个数字.将plist读入数组.NSLog数组,索引来自服务器的json值.
我的plist:
Key Type Value
Item 0 String New York
Item 1 String Atlanta
Run Code Online (Sandbox Code Playgroud)
我的代码:
得到Json
NSString *url_req=@"http://domain.com/index.php";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url_req]];
NSData *response = [NSURLConnection sendSynchronousRequest:request
returningResponse:nil error:nil];
NSError *jsonParsingError = nil;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:response
options:0 error:&jsonParsingError];
NSArray *cityArray = [json objectForKey:@"city"];
for (NSDictionary *alert in pestoArray ){
myLoc = [[alert objectForKey:@"location"] integerValue];
}
Run Code Online (Sandbox Code Playgroud)
Json工作得很好!
读取plist和nslog对应的值:
NSString *path = [[NSBundle mainBundle] pathForResource:@"townsList" ofType:@"plist"];
NSArray *arrayNo= [[NSArray alloc] initWithContentsOfFile:path];
NSLog(@"City %@",arrayNo[myLoc]);
Run Code Online (Sandbox Code Playgroud)
到目前为止arrayNo[myLoc]将返回null但 …
我AVPlayerItem和他有问题AVQueuePlayer.目前我有很多1-2秒长的音乐文件和一个按顺序播放它们的队列播放器.
我想要的是知道音乐文件何时刚刚开始播放而不是在播放完毕后(通过AVPlayerItemDidPlayToEndTimeNotification).
这是因为我想在加载和播放新文件时运行一个函数.
我的代码:
for (NSUInteger i = 0; i < [matchedAddr count]; i++)
{
NSString *firstVideoPath = [[NSBundle mainBundle] pathForResource:[matchedAddr objectAtIndex:i] ofType:@"wav"];
//NSLog(@"file %@",firstVideoPath);
avitem=[AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:firstVideoPath]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(currentItemIs:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:avitem];
[filelist addObject:avitem];
}
player = [AVQueuePlayer queuePlayerWithItems:filelist];
[player play];
- (void)currentItemIs:(NSNotification *)notification
{
NSString *asd=[seqArray objectAtIndex:currentColor];
currentColor=currentColor+1;
AVPlayerItem *p = [notification object];
[p seekToTime:kCMTimeZero];
if([asd isEqual:@"1"])
{
[UIView animateWithDuration:0.01 animations:^{
one.alpha = 0;
} completion:^(BOOL finished) {
[UIView …Run Code Online (Sandbox Code Playgroud) 我的 MySql 查询没什么问题:我有两个表:
表时间轴
id | date | text
1 2013-10-13 Hello
Run Code Online (Sandbox Code Playgroud)
餐桌代表
id | date | text
1 2013-10-12 Its me again
1 2013-10-11 What?
1 2013-10-10 Lorem ipsum
Run Code Online (Sandbox Code Playgroud)
我正在做的是UNION ALL时间线和代表。第一行应该始终是 时间线中的行(它总是一行),然后是代表表中的所有行,但按DESC顺序排列。
我的查询是以下一个(除了从 order by 之外可以正常工作)
select id,date,text from timeline UNION ALL select * from reps order by date desc
Run Code Online (Sandbox Code Playgroud)
想想像评论(位于顶部)的东西,并按降序对评论进行回复,最新的在前。
先感谢您。
我的问题MKPointAnnotation在地图上丢失了.我会解释一下.
场景:
从服务器读取JSON - >在地图上删除引脚 - >单击某个引脚时,打开一个带有传递给视图的参数的新视图.该参数必须绑定到引脚.
我的代码到目前为止:
JSON(仅限示例用途)
{"places":[{"lat":"30.03","lng":"40.31","id":"1"}]}
Run Code Online (Sandbox Code Playgroud)
读取JSON并向地图添加点:
NSString *markersJSON=@"http://test.com/json.php";
NSURLRequest *requestUsername = [NSURLRequest requestWithURL:[NSURL URLWithString:markersJSON]];
NSData *response = [NSURLConnection sendSynchronousRequest:requestUsername
returningResponse:nil error:nil];
NSError *jsonParsingError = nil;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:response
options:0 error:&jsonParsingError];
markerArray = [json objectForKey:@"places"];
for (NSDictionary *jsonObj in markerArray ){
latJSON=[jsonObj objectForKey:@"lat"];
lngJSON=[jsonObj objectForKey:@"lng"];
alertID=[jsonObj objectForKey:@"id"];
CLLocationCoordinate2D myCoordinate = {[latJSON doubleValue], [lngJSON doubleValue]};
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = myCoordinate;
point.title=[jsonObj objectForKey:@"title"];
point.subtitle=[jsonObj objectForKey:@"description"];
[self.mapView addAnnotation:point];
}
Run Code Online (Sandbox Code Playgroud)
单击注释时,使用与引脚对应的JSON中的变量"id"打开新视图.
- …Run Code Online (Sandbox Code Playgroud) ios ×2
mysql ×2
arrays ×1
ios7 ×1
json ×1
mapkit ×1
objective-c ×1
sql ×1
sql-order-by ×1
uistatusbar ×1
union-all ×1