小编tab*_*ber的帖子

GROUP_CONCAT和DISTINCT很棒,但我如何摆脱这些仍然存在的重复?

我有一个像这样设置的mysql表:

id   uid   keywords
--   ---   ---
1    20    corporate
2    20    corporate,business,strategy
3    20    corporate,bowser
4    20    flowers
5    20    battleship,corporate,dungeon

我希望我的输出看起来像是:

20    corporate,business,strategy,bowser,flowers,battleship,dungeon

但我最接近的是:

SELECT DISTINCT uid, GROUP_CONCAT(DISTINCT keywords ORDER BY keywords DESC) AS keywords
 FROM mytable
 WHERE uid !=0
 GROUP BY uid

哪个输出:

20    corporate,corporate,business,strategy,corporate,bowser,flowers,battleship,corporate,dungeon

有没有人有办法解决吗?非常感谢提前!

mysql database duplicates group-concat

2
推荐指数
1
解决办法
3449
查看次数

有什么方法可以在objective-c/iPhone/iOS SDK 中禁用CALayer 的rasterizationScale 插值/抗锯齿?

我想在设置myLayer.rasterizationScale = 0.01和设置时摆脱任何插值/抗锯齿/等myLayer.shouldRasterize = YES;

例子: 在此处输入图片说明

这是我正在尝试的代码:

- (void)drawRect:(CGRect)rect {
  CGContextRef ctx = UIGraphicsGetCurrentContext();
  CALayer *sourceLayer = self.delegate.sourceImageView.layer;
  sourceLayer.rasterizationScale = 0.01;
  sourceLayer.shouldRasterize = YES;
  [sourceLayer renderInContext:ctx];
  CGContextSetShouldAntialias(ctx, NO);
  CGContextSetAllowsAntialiasing(ctx, NO);
  CGContextSetInterpolationQuality(ctx, kCGInterpolationNone);
}
Run Code Online (Sandbox Code Playgroud)

预期的结果是图像将显示为厚实/像素化的位图。

有任何想法吗?谢谢!

编辑:添加了完整的 drawRect 代码,还尝试在 UIGraphicsGetCurrentContext 行之后立即移动 Antialias 函数。

编辑:尝试#2(失败!)

- (void)drawRect:(CGRect)rect
{
  CGContextRef ctx = UIGraphicsGetCurrentContext();
  CGContextSetShouldAntialias(ctx, NO);
  CGContextSetAllowsAntialiasing(ctx, NO);
  CGContextSetInterpolationQuality(ctx, kCGInterpolationNone);
  CALayer *layer = [CALayer layer];
  layer.contents = (id)[UIImage imageNamed:@"test.jpg"].CGImage;
  layer.frame = CGRectMake(0, 0, 320, 411);
  layer.rasterizationScale = 0.0001;
  layer.shouldRasterize = YES; …
Run Code Online (Sandbox Code Playgroud)

core-graphics calayer quartz-graphics quartz-2d ios4

2
推荐指数
1
解决办法
3128
查看次数

将BOOL值发送到iOS/iPhone上的Fragment Shader OpenGL ES 2.0

我是OpenGL ES 2.0的新手,所以请耐心等待...我想将BOOL标志传递到我的片段着色器中,以便在我的应用程序中发生某个触摸事件后,它会以不同的方式呈现gl_FragColor.我尝试使用vec2属性并将"伪造".x值作为我的"BOOL",但看起来OpenGL在着色器获得它之前将值从0.0归一化到1.0.所以即使在我的应用程序中我将它设置为0.0,而着色器正在做它的事情,该值最终将达到1.0.任何建议都将非常感激.

VertexAttrib代码:

// set up context, shaders, use program etc.

[filterProgram addAttribute:@"inputBrushMode"];
inputBrushModeAttribute = [filterProgram attributeIndex:@"inputBrushMode"];

bMode[0] = 0.0;
bMode[1] = 0.0;

glVertexAttribPointer(inputBrushModeAttribute, 2, GL_FLOAT, 0, 0, bMode);
Run Code Online (Sandbox Code Playgroud)

当前顶点着色器代码:

...
attribute vec2 inputBrushMode;
varying highp float brushMode;

void main()
{
    gl_Position = position;
    ...
    brushMode = inputBrushMode.x;
}
Run Code Online (Sandbox Code Playgroud)

当前片段着色器代码:

...
varying highp float brushMode;

void main()
{
    if(brushMode < 0.5) {
        // render the texture
        gl_FragColor = texture2D(inputImageTexture, textureCoordinate);
    } else {
        // cover things in yellow funk …
Run Code Online (Sandbox Code Playgroud)

iphone opengl-es fragment-shader ios opengl-es-2.0

2
推荐指数
1
解决办法
7405
查看次数

iPhone - AVAudioPlayer,kAudioSessionCategory_AmbientSound和iPod音乐

我在我的app委托中使用以下音频会话:

  AudioSessionInitialize(NULL, NULL, NULL, self);
  UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
  AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);

  AudioSessionSetActive(true);

我希望用户能够播放iPod音乐并同时使用我的应用程序,这很棒,工作正常...我的应用程序退出并允许iPod音乐播放.

我遇到的问题是...在用户退出我的应用程序后,进入iPod应用程序并暂停,当他们回到我的应用程序时,我的声音都没有用.就像它仍然认为iPod会话是活跃的,即使它没有播放任何音乐!

我基本上只是想在iPod音乐暂停后重新激活我的音频会话.既然这样,以后我曾经通过iPod应用程序播放的音乐,我完全无法让我的应用程序的声音回来,除非我重新编译.:( 有人有主意吗?

编辑:我忘了提到我正在使用AVAudioPlayer类的基本实现来播放我的应用程序的音频.

谢谢!

iphone audio ipod

1
推荐指数
1
解决办法
4523
查看次数

在iOS 4.2中iAds"无效的内容大小'ADBannerContentSizePortrait'传递给ADAdSizeForBannerContentSize"

2010年12月16日更新:使用4.2 SDK定位4.0设备时似乎存在类似问题...如果您使用Interface Builder创建广告横幅视图,您的应用会立即崩溃.弱链接iAd框架并在代码方面重新创建广告横幅实现是修复.感谢Ray Wenderlich撰写的这篇主题:http://www.raywenderlich.com/1371/how-to-integrate-iad-into-your-iphone-app

---

嗨,我刚尝试使用iOS 4.2 SDK(最终版)运行我的应用程序,并针对iOS 4.0设备,即使我的应用程序编译正常,我在运行时立即收到此错误...


*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
 reason: 'Invalid content size 'ADBannerContentSizePortrait' passed to
 ADAdSizeForBannerContentSize'
...
Run Code Online (Sandbox Code Playgroud)

我试过了...


- (void)viewDidLoad {
    self.bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
}
Run Code Online (Sandbox Code Playgroud)

...但没有运气,仍然得到相同的崩溃错误.在IB中看起来"尺寸"的唯一选项是"肖像,风景或两者",我猜iOS 4.0不是它的粉丝.

有人有什么建议吗?非常感谢.

iphone interface-builder ios4 iad ios-4.2

1
推荐指数
1
解决办法
2824
查看次数

iOS 5:UITabBarItem setFinishedSelectedImage:withFinishedUnselectedImage:not working/ignored

根据Apple 文档

我正在尝试在UITabBarItem上设置自定义完成的已选择和未选择的图像,如下所示:


...
DetailViewController *vc1 = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
UITabBarItem *vc1i = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemTopRated tag:100];
[vc1i setFinishedSelectedImage:[UIImage imageNamed:@"tab_bar_item_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_bar_item_normal.png"]];
[vc1 setTabBarItem:vc1i];
...
Run Code Online (Sandbox Code Playgroud)

基本上正在发生的事情是TabBar加载得很好,它只是完全忽略了标签栏项目的自定义.

我的目标是iOS5 +

图像是30x30透明PNG并存在于项目中.无法弄清楚我在这里俯瞰什么,但一定是什么东西!

这是在tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath方法中调用的,ala Ray Wenderlich的教程

有人有主意吗?

谢谢!

iphone uitabbaritem uitabbar ios ios5

1
推荐指数
1
解决办法
6550
查看次数

如何在远程 typeahead.js 中聚焦填充文本字段时禁用 typeahead:active

我正在使用 typeahead.js,它很棒,但这是我的用例:我有一个文本字段,当页面加载时,它已经在服务器端填充了一个字符串,所以我不希望建议菜单成为当用户聚焦文本字段时显示。

typeahead.js在聚焦文本字段时似乎总是显示菜单。这是有道理的,因为它minLength是 2 并且文本字段值类似于“Tony”(或其他)。但是我已经尝试在事件的回调中使用hint: false和调用,并且似乎都没有停止显示菜单。$('.typeahead').typeahead('close')typeahead:active

这是我正在使用的初始化代码:

$('#locationInput').typeahead({
    hint: false,
    highlight: false,
    minLength: 2
},
{
    name: 'locations',
    display: 'name',
    source: typeaheadLocations, // a simple Bloodhound instance
    templates: {
        suggestion: function(locationObj) {
            return $('<div>' + locationObj.name + '</div>');
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

还有就是当我焦点的文本字段,菜单实际显示,因为远程GET已运行之间有轻微的延迟。所以我猜我需要以某种方式阻止它,在它集中之后。

javascript typeahead.js twitter-typeahead

1
推荐指数
1
解决办法
965
查看次数

游戏状态singleton cocos2d,initWithEncoder总是返回null

我正在尝试在cocos2d中编写一个基本测试"游戏状态"单例,但由于某些原因加载应用程序时,从不调用initWithCoder.任何帮助将不胜感激,谢谢.

这是我的单身GameState.h:


#import "cocos2d.h"

@interface GameState : NSObject <NSCoding>
{
  NSInteger level, score;
  Boolean seenInstructions;
}

@property (readwrite) NSInteger level;
@property (readwrite) NSInteger score;
@property (readwrite) Boolean seenInstructions;

+(GameState *) sharedState;
+(void) loadState;
+(void) saveState;

@end
Run Code Online (Sandbox Code Playgroud)

...和GameState.m:


#import "GameState.h"
#import "Constants.h"

@implementation GameState

static GameState *sharedState = nil;

@synthesize level, score, seenInstructions;

-(void)dealloc {
  [super dealloc];
}

-(id)init {
  if(!(self = [super init]))
    return nil;  
  level = 1;
  score = 0;
  seenInstructions = NO;

  return self;
}

+(void)loadState {
  @synchronized([GameState …
Run Code Online (Sandbox Code Playgroud)

singleton nskeyedarchiver cocos2d-iphone nsdata iphone-sdk-3.0

0
推荐指数
1
解决办法
3539
查看次数